Php-implemented Baidu searches for the thief code of a certain weather. For example, php Baidu weather thief program. Copy the code as follows :? Php retrieves weather information captured by search for xx (place name) weather in baidu $ urlwww. baidu. coms? Wd % B1 % B example, php Baidu weather thief program.
The code is as follows:
// Retrieve weather information captured by searching for xx (place name) weather in Baidu
$ Url = "http://www.baidu.com/s? Wd = % B1 % B1 % BE % A9 % CC % EC % C6 % F8 "; // This is the return address for searching Beijing weather in Baidu
$ Content = file_get_contents ($ url );
Preg_match_all ('/
(. + ?) <\/Table>/Si', $ content, $ temp );
Preg_match_all ('/(. + ?) <\/Td>/Si', $ temp [1] [0], $ temp1 );
Var_dump ($ temp1 [1] [0]);
Output information:
String (243) "weather in Beijing
Today: The temperature ranges from 22 ℃ to 24 ℃. Daytime: cloudy, with large showers, and nighttime: cloudy. Dongfeng 2 to 1-2
Tomorrow: The temperature ranges from 23 ℃ to 28 ℃. Daytime: cloudy; nighttime: cloudy. Southeast wind level 2"
Bytes. The code is as follows :? Php // Get search in Baidu Inside xx (place name) weather crawled weather information $ url = "http://www.baidu.com/s? Wd = % B1 % B...