PHP Crawl Weather interface Data related issues, seek guidance

Source: Internet
Author: User
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.
  • Related Article

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.