Php ask collection code

Source: Internet
Author: User
Tags mysql tutorial

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.

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.

<? 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 ']); // 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 ("/<ol class =" result_list "> (. *) </ol>/ius", $ str, $ asklist); // obtain the Q & A list
// Echo $ asklist [1];
$ Url = "/<a target =" _ blank "href ="/z/(q. *. htm)/ius ";
@ Preg_match_all ($ url, $ asklist [1], $ urllist); // obtain 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 ("<pre>", "", str_replace ("</pre>", "", $ html ));
$ Html = str_replace ("<br/>", "<br/>", $ html );
// Echo $ html;
@ Preg_match ("/<div class =" question_main ">. * $ Art_title = $ ask_title [1];
@ Preg_match ("/<div class =" answer_con "> (. *) </div>/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 = "/(<a. *>) (. *) </a>/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 "<font color = red> adding ............................ </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 ""); // 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", "<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') "; // 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 ();
}
?>
<Link href = "style.css tutorial" rel = "stylesheet" type = "text/css"/>
<Table width = "700" border = "0" align = "center" cellspacing = "1" bgcolor = "# cccccc">
<Tr>
<Td height = "50" align = "center" bgcolor = "#00cc00"> </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"> collection Settings </a> <a href = "uninstall. php "onclick =" return confirm ('Are you sure you want to uninstall the collection plug-in '); "> uninstall collection </a> <a href =" cj_view.php "> View Collection records </a> <a href =" cj_help.php "> collect help </a> <a href = "baidu. php "target =" _ blank "> know collection </a> <a href =" wenwen. php "target =" _ blank "> query collection </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>

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.