PHP file_get_html无法正常工作 [英] PHP file_get_html is not working
问题描述
我已经使用了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);
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屋!