我正在运行一个
PHP脚本来抓取一个网页.它与许多站点工作正常,但一个站点失败,返回错误“HTTP / 1.1 505 HTTP版本不支持”.
@H_404_18@这是我的脚本(的一部分)
for($i = 0; $i < 1; $i++) { $page = file_get_contents("http://www.lovelybooks.de/stoebern/empfehlung/romantic fantasy/?seite=$i"); // do something with $page }
许多答案建议设置HTTP版本的显示.我已经设置0.9,1.0和1.1,但没有改变任何东西.实际上,标头似乎表明我的浏览器要求的HTTP版本和服务器所期望的HTTP版本匹配:
HTTP/1.1 200 OK Date: Mon,15 Dec 2014 09:01:15 GMT Server: Apache X-Powered-By: PHP/5.4.35 Keep-Alive: timeout=2,max=200 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html
请求标题:
GET /path/script.PHP HTTP/1.1 Host: www.mydoman.de User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:34.0) Gecko/20100101 Firefox/34.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: de,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip,deflate DNT: 1 Authorization: Basic MjQwMjE5Njc6MDcwNjIwMDc= Connection: keep-alive Cache-Control: max-age=0
还有什么可以错的?