Home  >  Article  >  Backend Development  >  求采集页数多里,怎样分开一部分一部分采,该怎么解决

求采集页数多里,怎样分开一部分一部分采,该怎么解决

WBOY
WBOYOriginal
2016-06-13 13:53:49965browse

求采集页数多里,怎样分开一部分一部分采
连接$url=array()里面一共有1000个页面的URL地址,

我写了一个采集类

foreach ($url as $key => $value){
$get_json_contetns = $caiji->getJson($value);
$excel_contetns[] = $caiji->getContents($get_json_contetns,$key);
}

像这样循化出来的$excel_contetns 就是我要采集的内容。

当我采集50页以下,还好,当页数多了,就采集超时了,还请大侠指点一下,我怎么处理一下???

------解决方案--------------------
将 $url 存入数据库
逐次从数据库读取 $value 执行采集,如遇新的 url,重复第一步
------解决方案--------------------
不要拘泥于“存不存数据库”,问题的实质是将单一的任务分解成多个任务来完成

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn