Php: Collection code _ PHP Tutorial

Source: Internet
Author: User
Php asks for the collection code. A free php collection code is provided. if you want to collect and ask, but you do not know how to write the collection program, here is a classic collection program for you. Provides a free php query collection code. if you want to collect and ask, but do not know how to write the collection program, here is a classic query collection program for you.

A free php Tutorial is provided to ask about the collection code. if you want to collect and ask, but you do not know how to write the collection program, here is a typical collection program for you.

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 ']); // Obtain the form submission question
$ Sp = "s". $ ask;
} Else
{
$ Sp = urlencode ($ _ get ['sp ']);
}
If (empty ($ _ get ['jl '])
{
$ _ Get ['jl '] = 1;
}
$ Jl = $ _ get ['jl '];
$ Pg = intval ($ _ get ['PG ']); // get the page number
$ Rs = intval ($ _ get ['Rs ']); // Obtain record parameters
If ($ rs> 9)
{
$ Rs = 0;
$ Pg ++;
}
If ($ pg> 51)
{
Echo "collection completed! Collect a total of ". urldecode ($ sp)." ". $ jl." records ";
Exit ();
}
If ($ sp) // starts with a set answer
{
$ Str = @ file_get_contents ("http://wenwen.soso.com/z/search.e? Sp ={$ sp} & pg ={$ pg }");
@ Preg_match ("/
    (.*)
/Ius ", $ str, $ asklist); // Obtain the Q & A list
// Echo $ asklist [1];
$ Url = "/@ preg_match_all ($ url, $ asklist [1], $ urllist); // get all 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 );
$ S1 = "/() (. *)/ius ";
$ Art_content = preg_replace ($ s1, $ {2}, trim ($ art_content ));
$ Word_arr = explode (",", iconv ("gbk", "UTF-8", $ cj_word ));
$ Word_allow = false; // whether Collection is allowed during initialization
$ 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 valid
{// Start database processing 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 a collection table
Mysql_query ($ SQL );
If (empty ($ t_catx_id) // if no category exists
{
$ 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 an article table
$ Jl ++; // add 1 to the record if it is stored in the database
// Process the database.
} Else
{
Echo "not long enough ";
}
} Else
{
Echo "the topic does not meet the requirements ";
}
} Else
{
Echo "already exists ";
}
$ Rs ++;
// Record the status of this collection
$ F_tt = urldecode ($ sp). "-- page number". $ 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. "'; script";
Exit ();
}
?>





Promo. you know how to ask the collection plug-in.





Collection settings unload collection View collection records collection help know collection ask collection


Tips: Ask about the collection code. if you want to collect and ask, but you don't know how to write the collection program, here is a typical collection program for you. Provided...

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.