【问题标题】:Use proxy with cURL?将代理与 cURL 一起使用?
【发布时间】:2014-03-06 23:01:57
【问题描述】:

我有这个问题,我需要每 200 个 cURL 请求更改我的 IP - 所以很明显代理会浮现在脑海中。问题是我想知道如何在哪里找到这些代理。有什么解决办法吗?谢谢!

更新: 好的,对于本网站的未来访问者,如果您想通过随机代理使用 cURL,请按照以下步骤操作: 1)您必须从代理站点上刮掉一个随机代理(以这个为例:http://www.hidemyass.com/proxy-list/10)...将代理保存到变量 2)然后您将使用此代码通过代理连接到站点:

$url = 'URL Here';
$proxy = 'SCRAPED  PROXY HERE';
//$proxyauth = 'user:password';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
$curl_scraped_page = curl_exec($ch);
curl_close($ch);

echo $curl_scraped_page;

【问题讨论】:

标签: php curl proxy ip proxies


【解决方案1】:

好的,因此对于本网站的未来访问者,如果您想通过随机代理使用 cURL,您可以这样做:1) 您必须从代理网站上抓取随机代理(以这个为例:http://www.hidemyass.com/proxy-list/10)...将代理保存到变量 2)然后您将使用以下代码通过代理连接到站点:

$url = 'URL Here';
$proxy = 'SCRAPED  PROXY HERE';
//$proxyauth = 'user:password';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
$curl_scraped_page = curl_exec($ch);
curl_close($ch);

echo $curl_scraped_page;

【讨论】:

  • 无需抓取,TheProxIsRight (theproxisright.com/help) 为当前活跃的代理提供免费 API。 JSON/CSV/XML/Text输出,可按国家、高可用、低延迟、类型、匿名、浏览器和google支持等查询。
猜你喜欢
  • 2016-10-31
  • 2012-11-06
  • 2010-12-11
  • 2015-07-22
  • 1970-01-01
  • 2011-04-01
  • 2016-06-26
  • 2016-02-14
  • 1970-01-01
相关资源
最近更新 更多