激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - PHP教程 - php知道與問問的采集插件代碼

php知道與問問的采集插件代碼

2019-11-10 14:50php教程網 PHP教程

看過一個百度小偷的網站也達到了pr6。收錄十萬多!! 在經過 薦禮啦 四十天的實踐之后 發現百度對這個確實挺友好的。

最近發現知道和問問小偷的版本越來越多了!! 
看過一個百度小偷的網站也達到了pr6。收錄十萬多!! 
在經過 薦禮啦 四十天的實踐之后 發現百度對這個確實挺友好的。 
從網站訪問來看 很多也是從百度搜索來的! 
所以用知道和問問來填充網站內容還是可行的。 
于是自己開發了一個知道 問問的采集插件 
原則上適合 php+mysql 并且文章是在一個表的程序 
知道采集代碼 

復制代碼代碼如下:


<?php 
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("/<a href=\"\/question\/(.*)\.html/iUs",$content,$uid); 
$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('<cq>',$content); 
$art_title=$arr[1]; 
$arr=explode('</cq>',$art_title); 
$art_title=$arr[0];//獲取標題結束 
//判斷內容是否符合 
$word_arr=explode(",",$cj_word); 
$word_allow=false;//初始化是否允許采集 
$word_count=count($word_arr);//關鍵字總數 
for($i=0;$i<$word_count;$i++) 

if(substr_count($art_title,$word_arr[$i])>0) 

$word_allow=1; 
$i=$word_count; 


if($word_allow)//如果滿足條件 

$arr=explode('<cd><pre>',$content); 
$contentQuestion=$arr[1]; 
$arr=explode('</pre></cd>',$contentQuestion); 
$contentQuestion=$arr[0]; 
echo "開始采集內容<br>"; 
echo "$art_title<br>"; 
@preg_match_all('/(<ca>|<cn>)<pre>(.*)<\/pre>(<\/ca>|<\/cn>)/iUs',$content,$answerArr); 
$answerArr=$answerArr[2]; 
if($arr_order==1)//隨機排序 

shuffle($answerArr); 

if($arr_order==2)//倒序 

$answerArr=krsort($answerArr);//倒序 

foreach($answerArr as $t) 

$answerTemp=str_replace('<ca><pre>','',$t); 
$answerTemp=str_replace('</pre></ca>','',$answerTemp); 
$answerTemp=str_replace('<cn><pre>','',$answerTemp); 
$answerTemp=str_replace('</pre></cn>','',$answerTemp); 
if(strlen($answerTemp)>$min_t1) 

$art_content .=$answerTemp."<br>"; 


//去除鏈接 
$s1="/(<a .*>)(.*)<\/a>/iUs"; 
$art_content=preg_replace($s1,${2},trim($art_content)); 
$art_content=str_replace("\n\r","<br>",$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(); 

?> 
<link href="style.css" rel="stylesheet" type="text/css" /> 
<table width="700" border="0" align="center" cellspacing="1" bgcolor="#CCCCCC"> 
<tr> 
<td height="50" align="center" bgcolor="#00CC00"><h1><a href="http://www.jianlila.com">薦禮啦</a>知道問問采集插件</h1></td> 
</tr> 
</table> 
<table width="700" border="0" align="center" cellspacing="1" bgcolor="#CCCCCC" style="margin-top:6px; margin-bottom:6px;"> 
<tr> 
<td height="30" align="center" bgcolor="#FFFFFF"><a href="cj_config.php">采集設置</a> <a href="uninstall.php" onclick="return confirm('您確定要卸載采集插件嗎');">卸載采集</a> <a href="cj_view.php">查看采集記錄</a> <a href="cj_help.php">采集幫助</a> <a href="baidu.php" target="_blank">知道采集</a>  <a href="wenwen.php" target="_blank">問問采集</a></td> 
</tr> 
</table> 
<table width="537" height="45" align="center" style="margin-top:30px;"><tr><td height="39"> 
<form id="form1" name="form1" method="get" action="baidu.php"> 
<div id="search"> 
<input name="searchStr" type="text" id="searchStr" value="<?php echo $searchStr; ?>" size="60" /> 
<input type="submit" name="searchBtn" id="searchBtn" value="知道偷偷" style="height:25px; line-height:25px;" /> 
</div> 
</form> 
</td></tr></table> 


問問采集代碼: 

復制代碼代碼如下:


<?php 
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("/<ol class=\"result_list\">(.*)<\/ol>/iUs",$str,$asklist);//獲取問答列表 
//echo $asklist[1]; 
$url="/<a target=\"_blank\" href=\"\/z\/(q.*\.htm)/iUs"; 
@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("<pre>","",str_replace("</pre>","",$html)); 
$html=str_replace("<br/><br/><br/>","<br/><br/>",$html); 
//echo $html; 
@preg_match("/<div class=\"question_main\">.*<h3>(.*)<\/h3>/iUs",$html,$ask_title); 
$art_title=$ask_title[1]; 
@preg_match("/<div class=\"answer_con\">(.*)<\/div>/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="/(<a .*>)(.*)<\/a>/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<$word_count;$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 "<font color=red>添加中............................</font><br>"; 
echo $art_title."<br>"; 
$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","<br>",$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(); 

?> 
<link href="style.css" rel="stylesheet" type="text/css" /> 
<table width="700" border="0" align="center" cellspacing="1" bgcolor="#CCCCCC"> 
<tr> 
<td height="50" align="center" bgcolor="#00CC00"><h1><a href="http://www.jianlila.com">薦禮啦</a>知道問問采集插件</h1></td> 
</tr> 
</table> 
<table width="700" border="0" align="center" cellspacing="1" bgcolor="#CCCCCC" style="margin-top:6px; margin-bottom:6px;"> 
<tr> 
<td height="30" align="center" bgcolor="#FFFFFF"><a href="cj_config.php">采集設置</a> <a href="uninstall.php" onclick="return confirm('您確定要卸載采集插件嗎');">卸載采集</a> <a href="cj_view.php">查看采集記錄</a> <a href="cj_help.php">采集幫助</a> <a href="baidu.php" target="_blank">知道采集</a>  <a href="wenwen.php" target="_blank">問問采集</a></td> 
</tr> 
</table> 
<form action="wenwen.php" method="post"> 
<table width="628" height="49" border="0" align="center"> 
<tr> 
<td width="413" align="right"><input name="ask" type="text" id="ask" size="50"></td> 
<td width="205"><input type="submit" name="button" id="button" value="問問采集" style=" padding-left:15px; padding-right:15px; height:25px; line-height:25px;"></td> 
</tr> 
</table> 
</form> 

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 黄色7777| av免费在线观看免费 | 成人福利视频网站 | 久久久鲁| 中文字幕专区高清在线观看 | 草草影院地址 | 久久精品久久精品久久精品 | 成人久久久久久久久久 | 免费黄色成人 | 9999免费视频 | 色柚视频网站ww色 | 美女又黄又www | 精品国产一区二区久久 | 国产一区二区三区四 | 深夜福利久久久 | 蜜桃视频在线免费播放 | 在线天堂中文在线资源网 | 亚洲片在线观看 | 艹男人的日日夜夜 | 久久精品欧美一区二区三区不卡 | 中文字幕国产亚洲 | 成人免费国产视频 | 成人毛片100部 | 成人福利视频在线观看 | 蜜桃传媒视频麻豆第一区免费观看 | 欧美a视频在线观看 | 天天干天天透 | 在线播放视频一区二区 | 亚洲综合无码一区二区 | 国产羞羞视频免费在线观看 | 3344永久免费| 欧美黄一级 | 激情综合婷婷久久 | 国产又白又嫩又紧又爽18p | 日本中文字幕久久 | 91高清完整版在线观看 | 免费观看一区二区三区视频 | 被啪羞羞视频在线观看 | 欧美亚洲国产一区二区三区 | 欧美一级www片免费观看 | 毛片在线免费播放 |