【发布时间】:2015-06-21 05:02:10
【问题描述】:
我使用了 simple_html_dom 库,但无法仅获取 1 个 URL 的 HTML 内容,但出现 503 错误。检查我下面的代码。
$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(http://www.amazon.com/gp/offer-listing/B001F0M4K8/ref=dp_olp_all_mbc/183-8463780-9861412?ie=UTF8&condition=new) [function.file-get-contents]:打开流失败:HTTP 请求失败! HTTP/1.1 503 Service Unavailable in D:\xampp\htdocs\webcrawler-amazon\webcrawler-amazon\simple_html_dom.php 第 76 行
我被困在这里所以请帮助我。
【问题讨论】:
-
可能是他们只允许某些用户代理或其他东西。 503 对我来说将是自定义生成的。一个简单的 file_get_contents 也失败了。因此,您可能必须尝试一些选项。当然,根据请求/获取的类型已经建议。
-
尝试使用 CURL 加载内容,如下例所示:stackoverflow.com/questions/18667441/…
标签: php file-get-contents simple-html-dom