我希望你能帮助我。该网站目前在线,我可以正常访问,但我似乎无法理解为什么这不起作用。
file_get_contents()
并fopen()
返回一个错误,说明如下:
PHP Warning: file_get_contents(http://www.hackforums.net): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /host/Users/Phizo/Desktop/stalker.php on line 29
现在我刚开始使用 cURL,因为我想尝试绕过这个 403,也没有运气。
$handle = curl_init();
$file = fopen('source.txt', 'w');
curl_setopt($handle, CURLOPT_URL, 'http://www.hackforums.net/');
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($handle, CURLOPT_HEADER, true);
curl_setopt($handle, CURLOPT_AUTOREFERER, true);
curl_setopt($handle, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:13.0) Gecko/20100101 Firefox/13.0.1');
curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($handle, CURLOPT_FILE, $file);
curl_exec($handle);
print_r(curl_getinfo($handle));
curl_close($handle);
fclose($file);
输出以下错误:
Fatal error: Maximum execution time of 30 seconds exceeded in D:\Hosting\6514439\html\zeonsglobal\admin\press_uploads\stalker.php on line 29