代码示例
在此页面上,您将找到有关如何使用代理的 Proxy Port 源的示例。
在第一种方法中,我们将尝试从 API 获取代理列表。
获取代理列表
$ curl 'https://api.proxy-port.com/scraping-proxy' \ -H 'X-API-KEY: $APIKEY'
from urllib.request import urlopen, Request import json url = 'https://api.proxy-port.com/scraping-proxy' headers = { 'X-API-KEY': '$APIKEY' } response = urlopen(Request(url, headers=headers)) data = json.load(response) print(data)
var options = { host: 'api.proxy-port.com', path: '/scraping-proxy', headers: { 'X-API-KEY': '$APIKEY' }, }; var req = https.request(options, function(res) { res.on('data', function(d) { console.log(JSON.parse(d.toString())); }); }); req.end();