代碼示例
Swiftproxy 讓開發者輕鬆將高品質住宅代理及靜態住宅代理整合到程式碼中。無論您使用的是 HTTP、HTTPS 或 SOCKS5 協議,我們的代理皆完全相容於主流程式語言與工具。
本節提供多種環境下的程式碼整合範例,幫助您在實際應用場景中實現代理支持,例如網頁爬蟲、數據彙整、SEO 監控等。
Python
// import requests
if __name__ == '__main__':
proxyip = "http://username_custom_zone_US:[email protected]:7878"
url = "http://ipinfo.io"
proxies = {
'http': proxyip,
}
data = requests.get(url=url, proxies=proxies)
print(data.text)Node.js
// import fetch from 'node-fetch';
import createHttpsProxyAgent from 'https-proxy-agent'
const username = 'username_custom_zone_us';
const password = 'password';
const proxy = 'us.swiftproxy.net:7878'
const agent = createHttpsProxyAgent(
`http://${username}:${password}@${proxy}`
);
const response = await fetch('http://ipinfo.io', {
method: 'get',
agent: agent,
});
console.log(await response.text());PHP
GO
Java
C#
Last updated
