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.