php 問問採集代碼_PHP教程

來源:互聯網
上載者:User
提供一款免費的php 問問採集代碼哦,如果你正想採集問問,但是又不知道怎麼寫採集程式,這裡為你提供一款經典的問問採集程式哦。

提供一款免費的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("/
    (.*)
/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<$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 "添加中............................
";
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("rn","
",$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 "";
exit();
}
?>





薦禮啦知道問問採集外掛程式






採集設定 卸載採集 查看採集記錄 採集協助 知道採集 問問採集


http://www.bkjia.com/PHPjc/444837.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/444837.htmlTechArticle提供一款免費的php 問問採集代碼哦,如果你正想採集問問,但是又不知道怎麼寫採集程式,這裡為你提供一款經典的問問採集程式哦。 提供...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.