本次修改原因:昨天用一个规则采集……3000篇文章,好不容易采到1200多的时候浏览器自动关了……又重新开始……又到了2000……浏览器超时……
思路:有没有一个像其他的下载工具那样可以断点续传的功能?
开始修改:
涉及修改文件:gather.php
打开文件,
第一步、将
Copy code
if($urldb[$page]){
$p=$page-1;
//只显示部分方便用户查看采集情况
$testgather || $content=get_word($content,1000);
$content=filtrate($content);
echo "正在采集第[$page]页,请耐心等待...<A href={$urldb[$p]} target=_blank>{$urldb[$p]}</A><hr>$content";
echo "<META HTTP-EQUIV=REFRESH CONTENT=′1;URL=?lfj=$lfj&action=$action&id=$id&system_type=$system_type&GetFile=$GetFile&file_dir=$file_dir&makesmallpic=$makesmallpic&showpic=$showpic&username=$username&fid=$fid&testgather=$testgather&page=$page′>";
exit;
}else{
$num=count($urldb);
if($testgather){
jump("测试采集完毕,模拟总共采集了{$num}篇,其实没有入数据库","index.php?lfj=$lfj&job=list",20);
}else{
jump("采集完毕,总共采集了{$num}篇","index.php?lfj=$lfj&job=list",10);
}
}
替换成
Copy code
if($urldb[$page]){
$p=$page-1;
//只显示部分方便用户查看采集情况
$testgather || $content=get_word($content,1000);
$content=filtrate($content);
echo "正在采集第[$page]页,请耐心等待...<A href={$urldb[$p]} target=_blank>{$urldb[$p]}</A><hr>$content";
echo "<META HTTP-EQUIV=REFRESH CONTENT=′1;URL=?lfj=$lfj&action=$action&id=$id&system_type=$system_type&GetFile=$GetFile&file_dir=$file_dir&makesmallpic=$makesmallpic&showpic=$showpic&username=$username&fid=$fid&testgather=$testgather&page=$page′>";
//断点续采开始记录
write_file(PHP168_PATH."cache/gather_record.php","<?php\r\n\$lastfinished=′$page|$id|$system_type|$GetFile|$file_dir|$makesmallpic|$showpic|$username|$fid|$testgather′;");
//断点续采结束记录
exit;
}else{
$num=count($urldb);
//断点续采开始记录
write_file(PHP168_PATH."cache/gather_record.php","");
//断点续采结束记录
if($testgather){
jump("测试采集完毕,模拟总共采集了{$num}篇,其实没有入数据库","index.php?lfj=$lfj&job=list",20);
}else{
jump("采集完毕,总共采集了{$num}篇","index.php?lfj=$lfj&job=list",10);
}
}
对于打了我发的采集自动放弃的补丁的朋友,需要将
Copy code
//采集内容出错自动放弃,开始
if(!$value2){
$page++;
echo "正在采集第[$page]页,请耐心等待............<hr><font color=red>发生错误:找不到匹配的内容,请仔细检查规则是否有错或<a href={$urldb[$page]} target=_blank><b>浏览出错页</b></a>............5秒后自动跳转到下一页。</font><br><br>出错页情况:<a href={$urldb[$page]} target=_blank><b>{$urldb[$page]}</b></a>";
if($urldb[$page]){
$p=$page-1;
echo "<META HTTP-EQUIV=REFRESH CONTENT=′5;URL=?lfj=$lfj&action=$action&id=$id&system_type=$system_type&GetFile=$GetFile&file_dir=$file_dir&makesmallpic=$makesmallpic&showpic=$showpic&username=$username&fid=$fid&testgather=$testgather&page=$page′>";
exit;
}else{
$num=count($urldb);
if($testgather){
jump("测试采集完毕,模拟总共采集了{$num}篇,其实没有入数据库","index.php?lfj=$lfj&job=list",20);
}else{
jump("采集完毕,总共采集了{$num}篇","index.php?lfj=$lfj&job=list",10);
}
}
}
//采集内容出错自动放弃,结束
//过滤文章前面无效内容
替换成
Copy code
//采集内容出错自动放弃,开始
if(!$value2){
$page++;
echo "正在采集第[$page]页,请耐心等待............<hr><font color=red>发生错误:找不到匹配的内容,请仔细检查规则是否有错或<a href={$urldb[$page]} target=_blank><b>浏览出错页</b></a>............5秒后自动跳转到下一页。</font><br><br>出错页情况:<a href={$urldb[$page]} target=_blank><b>{$urldb[$page]}</b></a>";
if($urldb[$page]){
$p=$page-1;
echo "<META HTTP-EQUIV=REFRESH CONTENT=′5;URL=?lfj=$lfj&action=$action&id=$id&system_type=$system_type&GetFile=$GetFile&file_dir=$file_dir&makesmallpic=$makesmallpic&showpic=$showpic&username=$username&fid=$fid&testgather=$testgather&page=$page′>";
//断点续采开始记录
write_file(PHP168_PATH."cache/gather_record.php","<?php\r\n\$lastfinished=′$page|$id|$system_type|$GetFile|$file_dir|$makesmallpic|$showpic|$username|$fid|$testgather′;");
//断点续采结束记录
exit;
}else{
$num=count($urldb);
//断点续采开始记录
write_file(PHP168_PATH."cache/gather_record.php","");
//断点续采结束记录
if($testgather){
jump("测试采集完毕,模拟总共采集了{$num}篇,其实没有入数据库","index.php?lfj=$lfj&job=list",20);
}else{
jump("采集完毕,总共采集了{$num}篇","index.php?lfj=$lfj&job=list",10);
}
}
}
//采集内容出错自动放弃,结束
第二步、将
Copy code
elseif($job=="list"&&$Apower[gather_list])
{
替换成
Copy code
elseif($job=="list"&&$Apower[gather_list])
{
//判断是否符合断点续采条件开始
if (file_exists(PHP168_PATH."cache/gather_record.php")){
include(PHP168_PATH."cache/gather_record.php");
if(isset($lastfinished)){
$lhb=array();
$lhb=explode(′|′,$lastfinished);
$page=$lhb[0]-1;//为了确保断掉的那篇文章的完整性,重新采一下
$id=$lhb[1];
$system_type=$lhb[2];
$GetFile=$lhb[3];
$file_dir=$lhb[4];
$makesmallpic=$lhb[5];
$showpic=$lhb[6];
$username=$lhb[7];
$fid=$lhb[8];
$testgather=$lhb[9];
$action=′gather_content′;//直接开始采集内容
$rsdb=$db->get_one("SELECT * FROM {$pre}gather_rule WHERE id=′$id′");
echo "<table width=′100%′ align=′center′ cellspacing=′2′ cellpadding=′5′ class=′tablewidth′><tr><td>提醒:您上次进行的 <font color=′red′><b>".$rsdb[webname]."[ID:".$id."]</b></font> 采集未完成。<a href=?lfj=$lfj&action=gather_content&id=$id&system_type=$system_type&GetFile=$GetFile&file_dir=$file_dir&makesmallpic=$makesmallpic&showpic=$showpic&username=$username&fid=$fid&testgather=$testgather&page=$page><font color=′red′><b>单击此处接着上次继续采集</b></font></a></td></tr></table>";
}
}
//判断是否符合断点续采条件结束
未进行严格测试,如果有错误请及时提出,注意文件备份!!!
以后不再修改采集器,期待官方能在新版本把我发的补丁集合到官方版本(如果不行,那么以后新版本中看情况我会发更新补丁),另外定时采集也希望由官方代为完成,最近有新的任务,可能没有时间弄,为此,实在很抱歉
思路:有没有一个像其他的下载工具那样可以断点续传的功能?
开始修改:
涉及修改文件:gather.php
打开文件,
第一步、将
Copy code
if($urldb[$page]){
$p=$page-1;
//只显示部分方便用户查看采集情况
$testgather || $content=get_word($content,1000);
$content=filtrate($content);
echo "正在采集第[$page]页,请耐心等待...<A href={$urldb[$p]} target=_blank>{$urldb[$p]}</A><hr>$content";
echo "<META HTTP-EQUIV=REFRESH CONTENT=′1;URL=?lfj=$lfj&action=$action&id=$id&system_type=$system_type&GetFile=$GetFile&file_dir=$file_dir&makesmallpic=$makesmallpic&showpic=$showpic&username=$username&fid=$fid&testgather=$testgather&page=$page′>";
exit;
}else{
$num=count($urldb);
if($testgather){
jump("测试采集完毕,模拟总共采集了{$num}篇,其实没有入数据库","index.php?lfj=$lfj&job=list",20);
}else{
jump("采集完毕,总共采集了{$num}篇","index.php?lfj=$lfj&job=list",10);
}
}
替换成
Copy code
if($urldb[$page]){
$p=$page-1;
//只显示部分方便用户查看采集情况
$testgather || $content=get_word($content,1000);
$content=filtrate($content);
echo "正在采集第[$page]页,请耐心等待...<A href={$urldb[$p]} target=_blank>{$urldb[$p]}</A><hr>$content";
echo "<META HTTP-EQUIV=REFRESH CONTENT=′1;URL=?lfj=$lfj&action=$action&id=$id&system_type=$system_type&GetFile=$GetFile&file_dir=$file_dir&makesmallpic=$makesmallpic&showpic=$showpic&username=$username&fid=$fid&testgather=$testgather&page=$page′>";
//断点续采开始记录
write_file(PHP168_PATH."cache/gather_record.php","<?php\r\n\$lastfinished=′$page|$id|$system_type|$GetFile|$file_dir|$makesmallpic|$showpic|$username|$fid|$testgather′;");
//断点续采结束记录
exit;
}else{
$num=count($urldb);
//断点续采开始记录
write_file(PHP168_PATH."cache/gather_record.php","");
//断点续采结束记录
if($testgather){
jump("测试采集完毕,模拟总共采集了{$num}篇,其实没有入数据库","index.php?lfj=$lfj&job=list",20);
}else{
jump("采集完毕,总共采集了{$num}篇","index.php?lfj=$lfj&job=list",10);
}
}
对于打了我发的采集自动放弃的补丁的朋友,需要将
Copy code
//采集内容出错自动放弃,开始
if(!$value2){
$page++;
echo "正在采集第[$page]页,请耐心等待............<hr><font color=red>发生错误:找不到匹配的内容,请仔细检查规则是否有错或<a href={$urldb[$page]} target=_blank><b>浏览出错页</b></a>............5秒后自动跳转到下一页。</font><br><br>出错页情况:<a href={$urldb[$page]} target=_blank><b>{$urldb[$page]}</b></a>";
if($urldb[$page]){
$p=$page-1;
echo "<META HTTP-EQUIV=REFRESH CONTENT=′5;URL=?lfj=$lfj&action=$action&id=$id&system_type=$system_type&GetFile=$GetFile&file_dir=$file_dir&makesmallpic=$makesmallpic&showpic=$showpic&username=$username&fid=$fid&testgather=$testgather&page=$page′>";
exit;
}else{
$num=count($urldb);
if($testgather){
jump("测试采集完毕,模拟总共采集了{$num}篇,其实没有入数据库","index.php?lfj=$lfj&job=list",20);
}else{
jump("采集完毕,总共采集了{$num}篇","index.php?lfj=$lfj&job=list",10);
}
}
}
//采集内容出错自动放弃,结束
//过滤文章前面无效内容
替换成
Copy code
//采集内容出错自动放弃,开始
if(!$value2){
$page++;
echo "正在采集第[$page]页,请耐心等待............<hr><font color=red>发生错误:找不到匹配的内容,请仔细检查规则是否有错或<a href={$urldb[$page]} target=_blank><b>浏览出错页</b></a>............5秒后自动跳转到下一页。</font><br><br>出错页情况:<a href={$urldb[$page]} target=_blank><b>{$urldb[$page]}</b></a>";
if($urldb[$page]){
$p=$page-1;
echo "<META HTTP-EQUIV=REFRESH CONTENT=′5;URL=?lfj=$lfj&action=$action&id=$id&system_type=$system_type&GetFile=$GetFile&file_dir=$file_dir&makesmallpic=$makesmallpic&showpic=$showpic&username=$username&fid=$fid&testgather=$testgather&page=$page′>";
//断点续采开始记录
write_file(PHP168_PATH."cache/gather_record.php","<?php\r\n\$lastfinished=′$page|$id|$system_type|$GetFile|$file_dir|$makesmallpic|$showpic|$username|$fid|$testgather′;");
//断点续采结束记录
exit;
}else{
$num=count($urldb);
//断点续采开始记录
write_file(PHP168_PATH."cache/gather_record.php","");
//断点续采结束记录
if($testgather){
jump("测试采集完毕,模拟总共采集了{$num}篇,其实没有入数据库","index.php?lfj=$lfj&job=list",20);
}else{
jump("采集完毕,总共采集了{$num}篇","index.php?lfj=$lfj&job=list",10);
}
}
}
//采集内容出错自动放弃,结束
第二步、将
Copy code
elseif($job=="list"&&$Apower[gather_list])
{
替换成
Copy code
elseif($job=="list"&&$Apower[gather_list])
{
//判断是否符合断点续采条件开始
if (file_exists(PHP168_PATH."cache/gather_record.php")){
include(PHP168_PATH."cache/gather_record.php");
if(isset($lastfinished)){
$lhb=array();
$lhb=explode(′|′,$lastfinished);
$page=$lhb[0]-1;//为了确保断掉的那篇文章的完整性,重新采一下
$id=$lhb[1];
$system_type=$lhb[2];
$GetFile=$lhb[3];
$file_dir=$lhb[4];
$makesmallpic=$lhb[5];
$showpic=$lhb[6];
$username=$lhb[7];
$fid=$lhb[8];
$testgather=$lhb[9];
$action=′gather_content′;//直接开始采集内容
$rsdb=$db->get_one("SELECT * FROM {$pre}gather_rule WHERE id=′$id′");
echo "<table width=′100%′ align=′center′ cellspacing=′2′ cellpadding=′5′ class=′tablewidth′><tr><td>提醒:您上次进行的 <font color=′red′><b>".$rsdb[webname]."[ID:".$id."]</b></font> 采集未完成。<a href=?lfj=$lfj&action=gather_content&id=$id&system_type=$system_type&GetFile=$GetFile&file_dir=$file_dir&makesmallpic=$makesmallpic&showpic=$showpic&username=$username&fid=$fid&testgather=$testgather&page=$page><font color=′red′><b>单击此处接着上次继续采集</b></font></a></td></tr></table>";
}
}
//判断是否符合断点续采条件结束
未进行严格测试,如果有错误请及时提出,注意文件备份!!!
以后不再修改采集器,期待官方能在新版本把我发的补丁集合到官方版本(如果不行,那么以后新版本中看情况我会发更新补丁),另外定时采集也希望由官方代为完成,最近有新的任务,可能没有时间弄,为此,实在很抱歉