PHP Crawl Weather Report Interface data problems, seek guidance
National Weather Bureau Free Weather Interface (Shenyang): http://www.weather.com.cn/data/cityinfo/101010100.html
This interface provides a JSON-formatted forecast data.
I do not know how to get this json in PHP, the following code found on the Internet
But the Httpgetrequest function is a custom function, and there is no prototype of this function on the web! Please expert guidance! JSON Weather Forecast
------Solution--------------------
$url = ' http://www.weather.com.cn/data/cityinfo/101070101.html ';
$s = file_get_contents ($url);
Print_r (Json_decode ($s, true));
Array
(
[Weatherinfo] = = Array
(
[City] = Shenyang
[Cityid] = 101070101
[Temp1] = 10 ℃
[Temp2] =-2 ℃
[Weather] = Cloudy
[IMG1] = D1.gif
[Img2] = N1.gif
[Ptime] = 08:00
)
)
------Solution--------------------
Httpgetrequest no need to ignore, anyway, the goal is to grasp the text down, just what means only, you can completely self-write
Direct access to the file_get_contents by the moderator, want to save a bit of traffic on the curl or socket to send a compression request
First use file_get_contents to finish the work, and so have time to learn curl, socket ... Go back and optimize.