PHP Ask the collection Code _php tutorial

Source: Internet
Author: User
Tags mysql tutorial
Provide a free PHP to ask the collection code Oh, if you are want to collect ask, but do not know how to write the collection process, here to provide you with a classic question collection program OH.

Provide a free PHP tutorial ask the collection code Oh, if you are trying to collect and ask, but do not know how to write the collection process, here to provide you with a classic question collection program OH.

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 '));//Get form submission issues
$SP = "s". $ask;
}else
{
$sp =urlencode ($_get[' SP ');
}
if (Empty ($_get[' JL ')))
{
$_get[' JL ']=1;
}
$JL =$_get[' JL ';
$PG =intval ($_get[' pg ');//Get pages
$rs =intval ($_get[' rs ');//Get the recorded parameters
if ($rs >9)
{
$rs = 0;
$PG + +;
}
if ($PG >51)
{
echo "Collection complete! Total acquisition ". UrlDecode ($SP)." ". $jl." Record ";
Exit ();
}
if ($SP)//start with a set answer
{
$str = @file_get_contents ("http://wenwen.soso.com/z/search.e?sp={$sp}&pg={$pg}");
@preg_match ("/
      (.*)
/ius ", $str, $asklist);//Get a list of questions and answers
echo $asklist [1];
$url = "/@preg_match_all ($url, $asklist [1], $urllist);//Get all the questions
$t = $urllist [1][$rs];
$uid = $t;
$suid = "ww{$uid}";
$SCT =mysql Tutorial _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);
$s 1= "/() (. *)/ius";
$art _content=preg_replace ($s 1,${2},trim ($art _content));
$word _arr=explode (",", Iconv ("GBK", "Utf-8", $CJ _word));
$word _allow=false;//Initialization allows acquisition
$word _count=count ($word _arr);//Total
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 Process Database Tutorial
if (strlen ($art _content) > $min _t2)
{
echo "Add in ....." ...............
";
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 "");//See if the title repeats
$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
{
$sql 2= "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
{
$sql 2= "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 ($sql 2);//Insert Article table
$JL ++;//If the record is stored in the database add 1
Process Database End
}else
{
echo "Insufficient length";
}
}else
{
echo "Subject does not meet the requirements";
}
}else
{
echo "already exists";
}
$rs + +;
Record the status of this collection
$f _tt= UrlDecode ($sp). " --pages ". $pg." Number of records ". $jl;
File_put_contents ("Ss.txt", $f _tt);
echo "";
Exit ();
}
?>





You know, ask the collection plugin.






Collection Setup uninstall capture view capture record collect help know collect ask Collect


http://www.bkjia.com/PHPjc/444837.html www.bkjia.com true http://www.bkjia.com/PHPjc/444837.html techarticle provide a free PHP to ask the collection code Oh, if you are want to collect ask, but do not know how to write the collection process, here to provide you with a classic question collection program OH. Provide ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.