cURL PHP 和 cURL

发布于 2024-11-07 14:09:51 字数 1576 浏览 0 评论 0原文

我有一个奇怪的问题。我正在大量使用 PHP cURL,但我有一个网站无法打开。

            $ch = curl_init();
            curl_setopt( $ch, CURLOPT_URL, $url );
            @unlink("/tmp/cookies.txt");
            curl_setopt( $ch, CURLOPT_COOKIEFILE, "/tmp/cookies.txt");
            curl_setopt( $ch, CURLOPT_COOKIEJAR, "/tmp/cookies.txt");
            curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
            curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 30 );
            curl_setopt( $ch, CURLOPT_TIMEOUT, 30 );
            curl_setopt( $ch, CURLOPT_HEADER, 0);
            curl_setopt( $ch, CURLOPT_REFERER, "http://www.gmail.com");
            curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/3.5.0.1");
            curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
            $page = curl_exec( $ch );
            $info = curl_getinfo($ch);

$info 返回:

[url] => MASKED
[content_type] => 
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0

我在服务器上安装了常规 cURL。 所以如果我这样做 卷曲domain.com

它有效! 这是同一个域。 我尝试清除防火墙,并让 cURL 使用 FRESH_CONNECT,以便它提取该域的最新 IP。 还是不行。想法?

I'm having a strange issue. I'm working heavily with PHP cURL, and I have a website that I just can't open.

            $ch = curl_init();
            curl_setopt( $ch, CURLOPT_URL, $url );
            @unlink("/tmp/cookies.txt");
            curl_setopt( $ch, CURLOPT_COOKIEFILE, "/tmp/cookies.txt");
            curl_setopt( $ch, CURLOPT_COOKIEJAR, "/tmp/cookies.txt");
            curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
            curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 30 );
            curl_setopt( $ch, CURLOPT_TIMEOUT, 30 );
            curl_setopt( $ch, CURLOPT_HEADER, 0);
            curl_setopt( $ch, CURLOPT_REFERER, "http://www.gmail.com");
            curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/3.5.0.1");
            curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
            $page = curl_exec( $ch );
            $info = curl_getinfo($ch);

$info returns :

[url] => MASKED
[content_type] => 
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0

I installed on the server regular cURL.
So if I do
curl domain.com

It works !!
It's the same domain.
I tried clearing up the firewall, and also having cURL use FRESH_CONNECT so it pulls the latest IP for the domain.
Still a no go. Ideas ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽心 2024-11-14 14:09:51

你的服务器IP可能被屏蔽了。

您是否尝试过:

 curl_setopt( $ch, CURLOPT_REFERER, $url);

那么引荐来源网址是实际的域?

您能给我域名以便我测试问题吗?

The ip of your server could be blocked.

Did you try :

 curl_setopt( $ch, CURLOPT_REFERER, $url);

So the referrer is the actual domain ?

Could you give me the domain name so I could test the problem?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文