search
HomeBackend DevelopmentPHP Tutorialphp知道与问问的采集插件代码_php技巧

最近发现知道和问问小偷的版本越来越多了!!
看过一个百度小偷的网站也达到了pr6。收录十万多!!
在经过 荐礼啦 四十天的实践之后 发现百度对这个确实挺友好的。
从网站访问来看 很多也是从百度搜索来的!
所以用知道和问问来填充网站内容还是可行的。
于是自己开发了一个知道 问问的采集插件
原则上适合 php+mysql 并且文章是在一个表的程序
知道采集代码

复制代码 代码如下:

session_start();
header("content-type:text/html;charset=gbk");
require("stole_config.php");
require("conn.php");
require("keyword.php");
$searchStr=$_GET["searchStr"];
$ss=explode(" ",$searchStr);//拆分搜索关键字
$word="";//关键字设为空
foreach($ss as $key=>$t)
{
if($key>0)
{
$word .="+";
}
$word .=urlencode($t);
}
$jl=intval($_GET['jl']);
if(isset($_GET['page']))
{
$page=intval($_GET['page']);
}else{
$page=1;
}
$rs=intval($_GET['rs']);
if($rs>=10)
{
$rs=0;
$page++;
}
if($page>76)
{
echo "采集完毕 ${jl}";
exit();
}
if(!empty($searchStr))//如果搜索
{
//获取问题页面
$content=@file_get_contents("http://zhidao.baidu.com/q?ct=17&lm=0&tn=ikaslist&pn=".(($page-1)*10)."&rn=10&word=".$word);
//获取问题列表
preg_match_all("/$uid=$uid[1];//获取详细页文章
$uid=$uid[$rs];
//判断数据是否存在
$suid="bd{$uid}";
$sct=mysql_query("select count(*) from {$table_prefix}c_article where suid='$suid' ");
$sct=mysql_fetch_array($sct);
$sct=$sct[0];
if($sct==0)
{
$content=@file_get_contents("http://zhidao.baidu.com/question/".$uid.".html") ;
$arr=explode('',$content);
$art_title=$arr[1];
$arr=explode('
',$art_title);
$art_title=$arr[0];//获取标题结束
//判断内容是否符合
$word_arr=explode(",",$cj_word);
$word_allow=false;//初始化是否允许采集
$word_count=count($word_arr);//关键字总数
for($i=0;$i{
if(substr_count($art_title,$word_arr[$i])>0)
{
$word_allow=1;
$i=$word_count;
}
}
if($word_allow)//如果满足条件
{
$arr=explode('
',$content); <br>$contentQuestion=$arr[1]; <br>$arr=explode('
',$contentQuestion);
$contentQuestion=$arr[0];
echo "开始采集内容
";
echo "$art_title
";
@preg_match_all('/(|)
(.*)(|)/iUs',$content,$answerArr); <br>$answerArr=$answerArr[2]; <br>if($arr_order==1)//随机排序 <br>{ <br>shuffle($answerArr); <br>} <br>if($arr_order==2)//倒序 <br>{ <br>$answerArr=krsort($answerArr);//倒序 <br>} <br>foreach($answerArr as $t) <br>{ <br>$answerTemp=str_replace('<ca><pre class="brush:php;toolbar:false">','',$t); <br>$answerTemp=str_replace('
','',$answerTemp); <br>$answerTemp=str_replace('
','',$answerTemp); <br>$answerTemp=str_replace('
','',$answerTemp);
if(strlen($answerTemp)>$min_t1)
{
$art_content .=$answerTemp."
";
}
}
//去除链接
$s1="/(
)(.*)/iUs";
$art_content=preg_replace($s1,${2},trim($art_content));
$art_content=str_replace("\n\r","
",$art_content);
if(strlen($art_content)>$min_t2)
{
$title_ct=mysql_query("select count(*) from {$table_prefix}c_article where art_title ='$art_title' ");//查看标题是否重复
$title_ct=@mysql_fetch_array($title_ct);
$title_ct=$title_ct[0];
if($title_ct>0)
{
$art_title .="{$same_title}{$title_ct}";
}
$art_time=date("Y-m-d");
$art_content=strtr($art_content,$keyword);
$sql="insert into {$table_prefix}c_article(art_title,art_content,art_time,art_author,suid) values('$art_title','$art_content','$art_time','$art_author','$suid')";//插入采集表
mysql_query($sql);
if(empty($t_catx_id))//如果无分类
{
$sql2="insert into {$t_table}({$t_art_title},{$t_art_content},{$t_art_time},{$t_artx_author}) values('$art_title','$art_content','$art_time','$art_author')";
}else
{
$sql2="insert into {$t_table}({$t_art_title},{$t_art_content},{$t_art_time},{$t_artx_author},{$t_catx_id}) values('$art_title','$art_content','$art_time','$art_author','$cat_id')";
}
mysql_query($sql2);//插入文章表
$jl++;
//数据库处理完毕
}else
{
echo "内容长度不够";
}
//获取文章内容结束
}else
{
echo "主题不符合要求";
}
}else
{
echo "已经存在";
}$rs++;
file_put_contents("bd.txt","采集{$searchStr}到第{$page}第{$rs}条");
echo "<script>location.href='baidu.php?searchStr=".urlencode($searchStr)."&page=".$page."&rs=".$rs."&jl=".$jl." ';</script>";
exit();
}
?>





荐礼啦知道问问采集插件






采集设置 卸载采集 查看采集记录 采集帮助 知道采集  问问采集







问问采集代码:
复制代码 代码如下:

session_start();
header("content-type:text/html;charset=utf-8");
require("stole_config.php");
require("conn.php");
require("keyword.php");
if(!empty($_POST['ask']))
{
$ask=urlencode(trim($_POST['ask']));//获取表单提交的问题
$sp="S".$ask;
}else
{
$sp=urlencode($_GET['sp']);
}
if(empty($_GET['jl']))
{
$_GET['jl']=1;
}
$jl=$_GET['jl'];
$pg=intval($_GET['pg']);//获取页数
$rs=intval($_GET['rs']);//获得 记录的参数
if($rs>9)
{
$rs=0;
$pg++;
}
if($pg>51)
{
echo "采集完毕! 总共采集 ".urldecode($sp)." ".$jl."条记录";
exit();
}
if($sp)//有设定答案才开始
{
$str=@file_get_contents("http://wenwen.soso.com/z/Search.e?sp={$sp}&pg={$pg}");
@preg_match("/
    (.*)/iUs",$str,$asklist);//获取问答列表
    //echo $asklist[1];
    $url="/@preg_match_all($url,$asklist[1],$urllist);//获取 所有的问题
    $t=$urllist[1][$rs];
    $uid=$t;
    $suid="ww{$uid}";
    $sct=mysql_query("select count(*) from {$table_prefix}c_article where suid='$suid' ");
    $sct=mysql_fetch_array($sct);
    $sct=$sct[0];
    if($sct==0)
    {
    $html=@file_get_contents("http://wenwen.soso.com/z/${t}");
    $html=str_replace("
    ","",str_replace("
    ","",$html));
    $html=str_replace("


    ","

    ",$html);
    //echo $html;
    @preg_match("/
    .*

    (.*)/iUs",$html,$ask_title);
    $art_title=$ask_title[1];
    @preg_match("/
    (.*)/iUs",$html,$answer);
    $j=count($answer)-1;
    $art_content="";//商品详细
    for($i=$j;$i>=1;$i--)
    {
    if(strlen($answer[$i])>$min_t1)
    {
    $art_content .= $answer[$i];
    }
    }
    $art_content=trim($art_content);
    $s1="/(
    )(.*)/iUs";
    $art_content=preg_replace($s1,${2},trim($art_content));
    $word_arr=explode(",",iconv("gbk","utf-8",$cj_word));
    $word_allow=false;//初始化是否允许采集
    $word_count=count($word_arr);//总数
    for($i=0;$i{
    if(substr_count($art_title,$word_arr[$i])>0)
    {
    $word_allow=1;
    $i=$word_count;
    }
    }
    if($word_allow)//如果合法
    { //开始处理数据库
    if(strlen($art_content)>$min_t2)
    {
    echo "添加中............................
    ";
    echo $art_title."
    ";
    $art_title=iconv('utf-8','gbk', $art_title);
    $title_ct=mysql_query("select count(*) from {$table_prefix}c_article where art_title ='$art_title' ");//查看标题是否重复
    $title_ct=@mysql_fetch_array($title_ct);
    $title_ct=$title_ct[0];
    if($title_ct>0)
    {
    $art_title .="{$same_title}{$title_ct}";
    }
    $art_content=iconv('utf-8','gbk',str_replace("\r\n","
    ",$art_content));
    $art_content=strtr($art_content,$keyword);
    $art_time=date("Y-m-d");
    $sql="insert into {$table_prefix}c_article(art_title,art_content,art_time,art_author,suid) values('$art_title','$art_content','$art_time','$art_author','$suid')";//插入采集表
    mysql_query($sql);
    if(empty($t_catx_id))//如果无分类
    {
    $sql2="insert into {$t_table}({$t_art_title},{$t_art_content},{$t_art_time},{$t_artx_author}) values('$art_title','$art_content','$art_time','$art_author')";
    }else
    {
    $sql2="insert into {$t_table}({$t_art_title},{$t_art_content},{$t_art_time},{$t_artx_author},{$t_catx_id}) values('$art_title','$art_content','$art_time','$art_author','$cat_id')";
    }
    mysql_query($sql2);//插入文章表
    $jl++;//如果存放数据库中 则记录加1
    //处理数据库结束
    }else
    {
    echo "长度不够";
    }
    }else
    {
    echo "主题不符合要求";
    }
    }else
    {
    echo "已经存在";
    }
    $rs++;
    //记录下本次采集 的状况
    $f_tt= urldecode($sp)."--页数".$pg." 记录数 ".$jl ;
    file_put_contents("ss.txt",$f_tt);
    echo "<script>location.href='wenwen.php?jl=".$jl."&sp=".$sp."&pg=".$pg."&rs=".$rs." ';</script>";
    exit();
    }
    ?>





    荐礼啦知道问问采集插件






    采集设置 卸载采集 查看采集记录 采集帮助 知道采集  问问采集









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
PHP Performance Tuning for High Traffic WebsitesPHP Performance Tuning for High Traffic WebsitesMay 14, 2025 am 12:13 AM

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

Dependency Injection in PHP: Code Examples for BeginnersDependency Injection in PHP: Code Examples for BeginnersMay 14, 2025 am 12:08 AM

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

PHP Performance: is it possible to optimize the application?PHP Performance: is it possible to optimize the application?May 14, 2025 am 12:04 AM

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

PHP Performance Optimization: The Ultimate GuidePHP Performance Optimization: The Ultimate GuideMay 14, 2025 am 12:02 AM

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.