我试图通过PHP解析/抓取网站来获取信息;卷曲但有时当前页面没有完成加载,因此脚本运行时不会发生任何事情。这是一个像这样简单的脚本。。。
...
curl_setopt($curl, CURLOPT_URL, $url);
$page = curl_exec($curl);
...
如果页面在(例如)60秒后没有完成加载,有没有一种方法可以在不中断完整脚本的情况下简单地重试加载同一页面?
如果有人能帮我找到实现这项任务的方法,那就太好了。
我试图通过PHP解析/抓取网站来获取信息;卷曲但有时当前页面没有完成加载,因此脚本运行时不会发生任何事情。这是一个像这样简单的脚本。。。
...
curl_setopt($curl, CURLOPT_URL, $url);
$page = curl_exec($curl);
...
如果页面在(例如)60秒后没有完成加载,有没有一种方法可以在不中断完整脚本的情况下简单地重试加载同一页面?
如果有人能帮我找到实现这项任务的方法,那就太好了。
您可以使用CURLOPT_TIMEOUT
,这是允许执行cURL函数的最大秒数。
curl_setopt($ch, CURLOPT_TIMEOUT, timeout_in_seconds);
简单的事情就是。。
$bol=true;
while($bol)
{
$page = curl_exec($curl);
if($page=="")//Or whatever curl_exec returns on timeout
$bol=true;
}
I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...
I would like to know the size of the movie I am watching on any video site [ if not possible on all video sites, then at least on YouTube ]. So is it possible, say I will specify the complete path ...
Is it possible to get the property of a class from string and then set a value? Example: string s = "label1.text"; string value = "new value"; label1.text = value; <--and some code that makes ...
I need to parse a xml string to obtain the xml DOM, the problem I m facing is with the self closing html tag like <br /> giving me the error of Tag mismatch expected </br>. I m aware this ...
The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...
I can easily do this with JQuery or PHP but I have a project for my Intro to C++ class and I thought it ll be pretty cool if I could mix C++ with some APIs like twitter, google, yahoo etc. Could you ...
I have never dealt with regular expressions before, and I am facing a problem here. The user has to input a text like Var1(0,enum1,enum2), and I have to check the syntax on the following manner:- 1- ...
I built a site a long time ago and now I want to place the data into a database without copying and pasting the 400+ pages that it has grown to so that I can make the site database driven. My site ...