Collect QQ alumni school data code

Source: Internet
Author: User
Tags foreach 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.

 

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.