服务器上的 cURL 超时,但本地主机上没有
陷入这个特定问题。我的代码可以从论坛(即 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,论坛正在使用 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.