Php obtains weather information based on the interface and finds a common weather interface from the Internet:
Shanghai: "http://www.weather.com.cn/adat/cityinfo/101020100.html"
Return json substring:
{"Weatherinfo": {"city": "shanghai", "city_en": "shanghai", "date_y": "August March 4, 2014", "date ":"", "week": "Tuesday", "fchh": "11", "cityid": "101020100", "temp1": "11C ~ 6C "," temp2 ":" 10C ~ 5C "," temp3 ":" 8C ~ 4C "," temp4 ":" 8C ~ 6C "," temp5 ":" 8C ~ 6C "," temp6 ":" 10C ~ 5C "," tempF1 ":" 51.8F ~ 42.8F "," tempF2 ":" 50F ~ 41F "," tempF3 ":" 46.4F ~ 39.2F "," tempF4 ":" 46.4F ~ 42.8F "," tempF5 ":" 46.4F ~ 42.8F "," tempF6 ":" 50F ~ 41F "," weather1 ":" light rain to cloudy "," weat22. "light rain", "weather4": "light rain", "weather4": "light rain ", "weather5": "Light rain overcast", "weather6": "Cloudy", "img1": "7", "img2": "1", "img3 ": "1", "img4": "2", "img5": "7", "img6": "99", "img7": "7", "img8 ": "99", "img9": "7", "img10": "2", "img11": "1", "img12": "99", "img_single ": "7", "img_title1": "light rain", "img_title2": "multi cloud", "img_title3": "multi cloud", "img_title4": "Overcast", "img_title5 ": "Light Rain", "img_title6": "light rain", "img_title7": "light rain", "img_title8 ": "Light Rain", "img_title9": "light rain", "img_title10": "Overcast", "img_title11": "Cloudy", "img_title12": "Cloudy", "img_title_single ": "Light Rain", "wind1": "Northeast wind 3-4 to north wind 4-5", "wind2": "North Wind 4-5 to northeast wind 3-4", "wind3 ": "Dongfeng 4-5", "wind4": "Dongfeng to northeast wind 4-5", "wind5": "Northeast wind 3-4", "wind6": "Northeast wind to Dongfeng 3-4 ", "fx1": "Northeast wind", "fx2": "North Wind", "fl1": "3-4 to 4-5", "fl2": "4-5 to 3-4 ", "fl3": "4-5", "fl4": "4-5", "fl5": "3-4", "fl6": "3-4", "index ": "Cold", "index_d": "It is recommended that you wear thick coats and sweaters. Old and weak people should wear coats, coat and sweater. "," Index48 ":" cold "," index48_d ":" It is recommended that you wear thick coats and sweaters. Old and weak people should wear coats, coat and sweater. "," Index_uv ":" weakest "," index48_uv ":" weakest "," index_xc ":" not suitable "," index_tr ":" suitable "," index_co ": "more comfortable", "st1": "10", "st2": "3", "st3": "9", "st4": "2 ", "st5": "7", "st6": "2", "index_cl": "not suitable", "index_ls": "not suitable", "index_ag ": "easy-to-use "}}
The content format is correct and the information is complete, but no date is specified.
Problem:
① How do I obtain the weather information on the day and 7 days in Shanghai?
Or
② Can I use regular expressions to match the information of China Weather Network?
Url: http://www.weather.com.cn/weather/101020100.shtml
Match the content I commented out, but this method is troublesome and inefficient.
Help...
Reply to discussion (solution)
A real-time interface is found:
Http://weatherapi.market.xiaomi.com/wtr-v2/weather? CityId = 101020100