Python 3: 날씨 정보 얻 기

위조 방지 코드: 어느 정도 의 고독 이 없 으 면 마음의 평화 가 있 을 수 없다.
파 이 썬 버 전
Python3.5.3
일기예보 웹 서비스 참고
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?op=getWeatherbyCityName
주의: 이 서 비 스 는 3 일간 의 일기 예 보 를 표시 할 수 있 습 니 다.
import urllib.request
from xml.dom.minidom import parseString
url = "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName"
while True:
    CityName = input("     (  q  ):")
    if CityName == 'q':
        break
    values = {"theCityName": CityName}
    data = urllib.parse.urlencode(values).encode(encoding='UTF8')
    req = urllib.request.Request(url, data)
    response = urllib.request.urlopen(req)
    the_page = response.read().decode("utf8")
    dom = parseString(the_page)
    W_data = dom.getElementsByTagName("string")
    i = 1
    for w in W_data:
        try:
            data = w.childNodes[0].data
            print(data)
        except IndexError as err:
            print("    !")

실행 결과:
     (  q  ):  
   
  
54511
54511.jpg
2017-8-13 17:53:46
23℃/29℃
8 13         
    
4.gif
4.gif
      :  :22℃;  /  :   1 ;  :90%;     : 。    : 。
     : ,    ,  SPF12-15、PA+   。
    :  ,     ,      。
    : ,   T 、         。
    :  ,  ,          。
    :   ,   ,            。
      : ,              。

22℃/30℃
8 14    
        
1.gif
1.gif
22℃/31℃
8 15        
        
1.gif
4.gif
            ,       39 ,  116 ,        ,        。             , 12 6 ,  1100  。                ,      ,      , 、   ,     10-12   。                。       ,                 “   ”。               ,          “ ”。   1045      、        ;   221          ,                ;   938   ,          、   、   、    。1949 10 1     ×××  。           ,          200  ,            、      、×××  、×××     ,     、   、                        。        7309 ,          42 ,        222 。           ,        。  ,         、    、   、             。
     (  q  ):

좋은 웹페이지 즐겨찾기