php ask for collection code_PHP tutorial

WBOY
Release: 2016-07-20 11:08:58
Original
805 people have browsed it

提供一款免费的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="";//Product details
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;//Whether initialization allows collection
$word_count=count($word_arr);//Total number
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 legal
{ //Start processing database tutorial
if(strlen($art_content)>$min_t2)
{
echo "Adding......................
";
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" ");//Check whether the title is repeated
$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')" ;//Insert collection table
mysql_query($sql);
if(empty($t_catx_id))//If no classification
{
$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);//Insert into the article table
$jl++;//If stored in the database Then add 1 to the record
//End of database processing
}else
{
echo "The length is not enough";
}
}else
{
echo "The subject is not enough" Meets the requirements";
}
}else
{
echo "Already exists";
}
$rs++;
//Record the status of this collection
$f_tt= urldecode($sp)."--Number of pages".$pg." Number of records".$jl;
file_put_contents("ss.txt",$f_tt);
echo "< script>location.href='wenwen.php?jl=".$jl."&sp=".$sp."&pg=".$pg."&rs=".$rs." '; ";
exit();
}
?>





RecommendationKnow Ask Collection Plug-in< /h1>





Collection settings Uninstall collection View collection record Collection Help Know the collection Ask the collection< ;/td>





< td width="205">



www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444837.htmlTechArticle provides a free php QQ collection code, if you want to collect QQ, but don’t know How to write a collection program? Here is a classic collection program for you. Provide...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template