我想向同一个域上的不同页面发送大约50个请求,然后使用DOM对象获取文章的urls。
问题是,这个请求数需要超过30秒。
for ($i = 1; $i < 51; $i++)
{
$url = 'http://example.com/page/'.$i.'/';
$client = new Zend_Http_Client($url);
$response = $client->request();
$dom = new Zend_Dom_Query($response); // without this two lines, execution is also too long
$results = $dom->query('li'); //
}有没有什么方法可以加快速度呢?
发布于 2013-07-03 20:37:44
我想不出一个方法来加速它,但是你可以在PHP中增加超时限制,如果这是你关心的:
for($i=1; $i<51; $i++) {
set_time_limit(30); //This restarts the timer to 30 seconds starting now
//Do long things here
}https://stackoverflow.com/questions/17444930
复制相似问题