The China Meteorological Bureau provides three API interfaces for weather queries:
"1" http://www.weather.com.cn/data/sk/101190101. html
"2" http://www.weather.com.cn/data/cityinfo/101190101. html
"3" http://m.weather.com.cn/data/101190101. html
Returns data in JSON format, the first and second interfaces return real-time weather data for the current day, and a third returns the weather for the next five days.
The numbers in the address indicate the city's code: 101190101 for Nanjing (the method to get the city code is explained below)
An example of the return data for the third interface is described below:
- {
- Weatherinfo: {
- City: "Nanjing",
- City_en: "Nanjing",
- Date_y: "September 8, 2013",
- Date: " ",
- Week: "Sunday",
- Fchh: "",
- Cityid: "101190101", //city Code
- Temp1: "22℃~30℃", //First day (day) maximum drinking minimum temperature (Celsius temperature)
- Temp2: "23℃~29℃", //next day highest drinking minimum temperature (Celsius temperature)
- Temp3: "22℃~28℃", //third day maximum drinking minimum temperature (Celsius temperature)
- Temp4: "23℃~30℃", //fourth day maximum drinking minimum temperature (Celsius temperature)
- TEMP5: "24℃~28℃", //fifth day maximum drinking minimum temperature (Celsius temperature)
- TEMP6: "23℃~28℃", //sixth day maximum drinking minimum temperature (Celsius temperature)
- TempF1: "71.6℉~86℉", //First day (day) maximum drink minimum temperature (Fahrenheit temperature)
- TempF2: "73.4℉~84.2℉", //The next day maximum drinking minimum temperature (Fahrenheit temperature)
- TempF3: "71.6℉~82.4℉", //third day maximum drinking minimum temperature (Fahrenheit temperature)
- TempF4: "73.4℉~86℉", //fourth day maximum drink minimum temperature (Fahrenheit temperature)
- TempF5: "75.2℉~82.4℉", //fifth day maximum drink minimum temperature (Fahrenheit temperature)
- TempF6: "73.4℉~82.4℉", //sixth day maximum drink minimum temperature (Fahrenheit temperature)
- Weather1: "Cloudy", //First day (day) weather
- Weather2: "Light Rain", //Next day weather
- Weather3: "drizzle",
- Weather4: "Yin",
- WEATHER5: "Light rain turns to cloudy",
- WEATHER6: "moderate rain turns yin",
- IMG1: "1", //Weather Picture Code 1 for the first day
- Img2: "2", //Weather Picture Code 2 for the first day
- IMG3: "7", //weather image for the next day code 1
- IMG4: "The next day" Weather image code 2
- IMG5: "7",
- Img6: " the",
- Img7: "2",
- Img8: " the",
- IMG9: "7",
- IMG10: "8",
- IMG11: "8",
- Img12: "2",
- Img_single: "2"
- Img_title1: "Cloudy", //First day weather picture 1 title
- Img_title2: "Yin", //The first day of the weather Picture 2 title
- Img_title3: "drizzle", //The next day weather picture 1 title
- Img_title4: "drizzle", //The next day weather Picture 2 title
- Img_title5: "drizzle",
- Img_title6: "drizzle",
- Img_title7: "Yin",
- Img_title8: "Yin",
- Img_title9: "drizzle",
- Img_title10: "Moderate rain",
- IMG_TITLE11: "Moderate rain",
- Img_title12: "Yin",
- Img_title_single: "Yin",
- Wind1: "Dongfeng level 3-4", //First day wind direction range
- Wind2: "Dongfeng level 3-4", ///second day wind direction range
- Wind3: "North wind turn to northeast 3-4",
- Wind4: "3-4 levels Northeast",
- Wind5: "The northeast winds turn to the westerly level 3-4",
- Wind6: "West wind turn westerly 3-4",
- FX1: "Dongfeng",
- FX2: "Dongfeng",
- FL1: "Level 3-4", //First day wind range
- FL2: "Level 3-4",
- FL3: "Level 3-4",
- FL4: "Level 3-4",
- FL5: "Level 3-4",
- FL6: "Level 3-4",
- Index: "hot", //24-hour dressing index
- Index_d: "hot weather, it is recommended that short skirts, shorts, thin jackets, t-shirts and other summer clothing." ", //Suggest
- index48: "hot", //48-hour dressing index
- Index48_d: "hot weather, it is recommended that short skirts, shorts, thin jackets, t-shirts and other summer clothing." ", //Suggest
- INDEX_UV: "Weak", //24 hours UV
- INDEX48_UV: "Weak", //48 hours UV
- INDEX_XC: "not suitable", //car wash
- INDEX_TR: "fit", //Travel
- Index_co: "more comfortable", //Comfort
- ST1: "a",
- ST2: "a",
- ST3: "qi",
- ST4: "+",
- ST5: "+",
- ST6: "",
- INDEX_CL: "more suitable", //morning exercise
- Index_ls: "not very suitable", //drying
- Index_ag: "very easy Hair" //Allergy
- }
- }
Ways to get City code:
1. Get a list of provinces first
Http://www.weather.com.cn/data/city3jdata/china.html
This link returns an array containing the province code and the province name in JSON format
- {
- 10101: "Beijing",
- 10102: "Shanghai",
- .... ,
- 10119: "Jiangsu",
- }
2. Get a list of cities by the province code obtained above:
such as Jiangsu City Code is: 10119, through the following link to get a list of cities in Jiangsu Province
Http://www.weather.com.cn/data/city3jdata/provshi/10119.html
- {
- : "Lianyungang",
- One: "Changzhou",
- ...
- 01: "Nanjing",
- }
3. Get the regional information under the city
To get the city code from the previous step, such as: Nanjing is 01
01 received the first step to obtain the province code after obtaining 1011901 representative of Nanjing City, Jiangsu Province
Use the link below to get the region information for Nanjing, Jiangsu Province, and add the bold part to the code you just generated
http://www.weather.com.cn/data/city3jdata/station/1011901. html
- {
- "Nanjing",
- : "Lishui",
- "Gaochun",
- Note: "Jiangning",
- A: "Liuhe",
- : "Jiangpu",
- : "Pukou"
- }
4. Get the area code
The area code obtained above is as follows: (on behalf of Nanjing area) received the third step of Jiangsu province Nanjing code 1011901
Get 101190101 representative of Jiangsu province Nanjing Nanjing City Code.
This string of code is what we need.
http://m.weather.com.cn/data/101190101. html
Put it in this link and we can get the weather information of Nanjing City, Jiangsu province Nanjing!
Below is a SQL file that provides a demo address and a city Code comparison table for the Weather query tool I have written.
Weather query based on API interface provided by China Meteorological Bureau