file_get_contents返回403禁止 [英] file_get_contents returns 403 forbidden

查看:752
本文介绍了file_get_contents返回403禁止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个网站。我在我的本地机器上,它的工作非常精细。当我在我的服务器上执行相同的,它显示403禁止的错误。
我正在使用 PHP简单HTML DOM解析器。我在服务器上得到的错误是:

I am trying to make a sitescraper. I made it on my local machine and it works very fine there. When I execute the same on my server, it shows a 403 forbidden error. I am using the PHP Simple HTML DOM Parser. The error I get on the server is this:


警告:
file_get_contents(http://example.com/viewProperty。 html?id = 7715888)
[function.file-get-contents]:失败
打开流:HTTP请求失败!
HTTP / 1.1 403禁止在
/home/scraping/simple_html_dom.php on
第40行

Warning: file_get_contents(http://example.com/viewProperty.html?id=7715888) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /home/scraping/simple_html_dom.php on line 40

触发它的代码行是:

$url="http://www.example.com/viewProperty.html?id=".$id;

$html=file_get_html($url);

我已经检查了服务器上的php.ini,allow_url_fopen为On。可能的解决方案可以使用curl,但我需要知道我在哪里出错。

I have checked the php.ini on the server and allow_url_fopen is On. Possible solution can be using curl, but I need to know where I am going wrong.

推荐答案

脚本,但使用您请求的资源。网络服务器返回了禁止状态代码。

This is not a problem with your script, but with the resource you are requesting. The web server is returning the "forbidden" status code.

它可能阻止PHP脚本以防止抓取,或者您的IP请求过多。

It could be that it blocks PHP scripts to prevent scraping, or your IP if you have made too many requests.

您应该向远程服务器的管理员咨询。

You should probably talk to the administrator of the remote server.

这篇关于file_get_contents返回403禁止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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