【发布时间】:2019-01-15 17:59:08
【问题描述】:
我看到资源提到在抓取网站时使用代理,我一直在使用纯 PHP 和一些 PHP 库。
例如:
file_get_contents('http://example.com');
或使用 CURL:
$url = "http://example.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
$response = curl_exec($ch);
curl_close($ch);
有一段时间我没有遇到严重的问题,只是有时我从file_get_contents 收到一些错误,但之后它什么也没做。
我应该在这样做的时候使用代理吗?
如果是这样,我如何获得代理?
【问题讨论】:
标签: php curl web-scraping proxy file-get-contents