Weather query is used when developing a website. Because it is based on Wordpress, there are many restrictions. First, create a [weather. php] file and check the code :? Php get weather $ urlm.weather.com. cndata; $ id101181101; Jiaozuo code $ datafile_get_contents ($ url. $ id
Weather query is used when developing a website. Because it is based on Wordpress, there are many restrictions. First, create a [weather. php] file and check the code :? Php // get weather $ url = 'HTTP: // m.weather.com.cn/data/'; $ id = '000000'; // Jiaozuo code $ data = file_get_contents ($ url. $ id
Weather query is used when developing a website. Because it is based on Wordpress, there are many restrictions. First, create a [weather. php] file and check the Code:
Weatherinfo-> city. ':'. $ obj-> weatherinfo-> weather1. '. $ obj-> weatherinfo-> temp1;
For:
$ Url = 'HTTP: // m.weather.com.cn/data/'; $ id = '000000'; // Jiaozuo code $ data = file_get_contents ($ url. $ id .'.html ');
Can be abbreviated:
$data = file_get_contents('http://m.weather.com.cn/data/101181101.html');
For:
$obj=json_decode($data);
It converts the obtained json data into an object for convenient calling;
Then the last sentence:
echo $obj->weatherinfo->city.':'.$obj->weatherinfo->weather1.' '.$obj->weatherinfo->temp1;
Is to obtain the specified data and output it in a certain format,
$ Obj-> weatherinfo-> city // city $ obj-> weatherinfo-> weather1 // today's weather $ obj-> weatherinfo-> temp1 // Today's temperature
Other parameters can be viewed in the http://m.weather.com.cn/data/101181101.html
Finally
You can.