服务器上的 cURL 超时,但本地主机上没有

发布于 2024-10-09 09:01:44 字数 1057 浏览 0 评论 0原文

陷入这个特定问题。我的代码可以从论坛(即 www.q8yat.net )获取大量页面。现在我有一个循环,使用curl 从论坛获取页面。在我的本地主机上一切正常。但是,当我将文件上传到服务器上并尝试获取页面时,通常会在加载固定数量的页面后收到连接超时错误,但情况并非总是如此。我正在使用的curl选项是:

$options = array(
     CURLOPT_RETURNTRANSFER => true,     // return web page
     CURLOPT_HEADER         => false,    // don't return headers
     CURLOPT_FOLLOWLOCATION => true,     // follow redirects
     CURLOPT_ENCODING       => "",       // handle all encodings
     CURLOPT_USERAGENT      => "spider", // who am i
     CURLOPT_AUTOREFERER    => true,     // set referer on redirect
     CURLOPT_CONNECTTIMEOUT => 1,      // timeout on connect
     CURLOPT_TIMEOUT        => 1200,      // timeout on response
     CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects

 );

我的服务器的phpinfo:http://topics4today。 com/public/02_12_2010/fcrawl/src/phpinfo.php

好吧,我相信论坛正在使用 apache 模块:'mod_bwlimited' 来限制我可以根据我的 IP 请求的数据量。一种可能性。

Stuck with this particular issue. I have code that get lots of pages from a forum i.e. www.q8yat.net . Now I have a loop that uses curl to get the pages from the forum. Everything works fine on my localhost. BUt when I upload the files on my server and try to get the pages I get a connection timeout error usually after a fixed amount of pages are loaded but thats not always. The curl options I am using are :

$options = array(
     CURLOPT_RETURNTRANSFER => true,     // return web page
     CURLOPT_HEADER         => false,    // don't return headers
     CURLOPT_FOLLOWLOCATION => true,     // follow redirects
     CURLOPT_ENCODING       => "",       // handle all encodings
     CURLOPT_USERAGENT      => "spider", // who am i
     CURLOPT_AUTOREFERER    => true,     // set referer on redirect
     CURLOPT_CONNECTTIMEOUT => 1,      // timeout on connect
     CURLOPT_TIMEOUT        => 1200,      // timeout on response
     CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects

 );

phpinfo of my server: http://topics4today.com/public/02_12_2010/fcrawl/src/phpinfo.php

Ok i believe the forum is using an apache module:' mod_bwlimited' to limit the amount of data I can request based on my ip. A possibility.

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

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

发布评论

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

评论(1

请恋爱 2024-10-16 09:01:44

好的,论坛正在使用 apache 模块:'mod_bwlimited' 来限制我可以根据我的 IP 请求的数据量。可以通过在每次运行脚本时仅请求有限数量的页面来解决问题。例如,您的脚本运行,请求 2 页,停止,然后再次启动(使用 javascript 计时器)并请求另外 2 页,这会循环进行。

Ok the forum is using an apache module:' mod_bwlimited' to limit the amount of data I can request based on my ip. Issue can be solved by requesting only a limited number of pages in every run of the script. E.g. your script runs, asks for 2 pages, stops, then starts again ( using javascript timer ) and asks for 2 more pages and this goes on in a loop.

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