PHP file_get_html无法正常工作 [英] PHP file_get_html is not working

查看:135
本文介绍了PHP file_get_html无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用了simple_html_dom库,但是我无法仅获取1个URL的HTML内容,但是却出现503错误.检查我下面的代码.

I have used simple_html_dom library but i can not get HTML content only for 1 URL but i am getting 503 error. Check my below code.

$base = 'http://www.amazon.com/gp/offer-listing/B001F0M4K8/ref=dp_olp_all_mbc/183-8463780-9861412?ie=UTF8&condition=new';

echo $html = file_get_html($base);

错误: 警告:file_get_contents(

Error : Warning: file_get_contents(http://www.amazon.com/gp/offer-listing/B001F0M4K8/ref=dp_olp_all_mbc/183-8463780-9861412?ie=UTF8&condition=new) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 503 Service Unavailable in D:\xampp\htdocs\webcrawler-amazon\webcrawler-amazon\simple_html_dom.php on line 76

我被困在这里,请帮助我.

I am stuck here so please help me.

推荐答案

我认为,服务器只是阻止了您的请求,您将无法使用简单的HTTP请求从中获取数据.

I think, server just blocks your request, you will not be able to fetch data from it, using simple HTTP requests.

您可以尝试使用curl,代理或同时使用两者(可以使用针对此问题的解决方案,例如: AngryCurl RollingCurl )

You can try using curl, proxies, or both (there are ready to use solutions for this, like: AngryCurl, or RollingCurl)

这篇关于PHP file_get_html无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆