Using China weather forecast interface to realize simple weather forecast

Source: Internet
Author: User

  This article mainly introduces the use of China weather forecast interface to achieve a simple weather forecast example, we refer to the use of the bar

  Code as follows: <?php header ("Content-type:text/html;charset=utf-8"); $weather = file_get_contents ("http://www.weather.com.cn/data/sk/101280601.html"); echo $weather?>      code as follows: <html> <head> <meta http-equiv= "Content-type" content= " TEXT/HTML;CHARSET=GBK "/> <style type= text/css" > all span {font:bold 30px/50px "Arial"; color:red > <title> Weather </title> </head> <body> <div class= "All" > This is: <span class= "Place" > City </span&gt, the temperature is <span class= "temp" > Temperature </span> Wind Direction: <span class= "Wind" > Direction </span&gt Wind: <span class= "Windpower" > Wind </span> </div> <script type= "Text/javascript" src= "HTTP://127.0.0.1/" Jquery.js "></script> <script type=" Text/javascript "> $ (function () {$.ajax ({//Requested address URL:" http:// 127.0.0.1/weather.php ",///////////////////////////////////////////////////////Success:function '); Get element var $place with jquery-1.8.2 = $ ('. Place '), $temp = $ (". Temp"), $wind = $ (". Wind"), $windPower = $ (". Windpower"); Place the returned data in the appropriate location $place. html (od["Weatherinfo"] ["City"]); $temp. HTML (od["Weatherinfo"] ["temp"] + "°"); $wind. HTML (od["Weatherinfo"] ["WD"]); $windPower. HTML (od["Weatherinfo"] ["WS"]); } }); }) </script> </body> </html>  

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.