Collect QQ alumni school data code

Source: Internet
Author: User
Tags php tutorial

Collect qq alumni school data code

<? Php Tutorial
/**
* Collect qq alumni school data
 *
* @ Package zwframe
*/
 
// ######################## Set php environment ############ ###############
Error_reporting (e_all &~ E_notice );
 
// ##################### Define important constants ############### ########
Define ('This _ script', 'qqschools ');
 
// ######################### Require back-end ######### ###################
Require_once ('./global. Php ');
Set_time_limit (0 );
 
/**
* Collection link
* University: http://api.pengyou.qq.com/index.php? Mod = school & act = selector & schooltype = 0 & country = 0 & province = 11 & prefix = B
*/
 
$ Prefixs = range ('A', 'z ');
$ Areas = range (11, 82 );
 
Foreach ($ areas as $ area)
{
$ SQL = array ();
Foreach ($ prefixs as $ prefix)
 {
$ Html = '';
$ Html = file_get_contents ("http://api.pengyou.qq.com/index.php? Mod = school & act = selector & schooltype = 0 & country = 0 & province = {$ area} & prefix = {$ prefix }");
Preg_match_all ("# webpage effects: choose_school (d +), '([^'] +) ') # I", $ html, $ schools );
Unset ($ html );
 
If (! Empty ($ schools [2])
  {
Foreach ($ schools [2] as $ key => $ value)
   {
$ SQL [] = "('{$ area} 0000', '{$ value}', 0, '{$ prefix }')";
   }
  }
 }
Unset ($ schools );
 
If (! Empty ($ SQL ))
 {
Ob_end_clean ();
// Database writing tutorial
$ Query = "insert into schools (areaid, schoolname, schooltype, prefix) values". implode (',', $ SQL );
$ Zwframe-> db-> query_write ($ query );
Echo "{$ area} 0000 University data import completed... <br/> ";
Unset ($ SQL, $ query );
Flush ();
Sleep (1 );
 }
}
?>

Note:
When uploading a file, you must declare that the file is uploaded as binary data (enctype = "multipart/form-data "). when binary data is uploaded, $ _ request cannot obtain the input equivalent. (file can be obtained)

You can use $ _ post or $ _ get to obtain the data.

 

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.