MUstar

IoT Python3 0906 - brabra

Sep 6th, 2017
118
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import urllib.request
  2. import urllib.parse
  3.  
  4. def processor(code):
  5.     API = "http://www.kma.go.kr/weather/forecast/mid-term-rss3.jsp"
  6.  
  7.     values = {
  8.         'stnId' : code
  9.     }
  10.     params = urllib.parse.urlencode(values)
  11.  
  12.     url = API + "?" + params
  13.     print("url=",url)
  14.  
  15.     data = urllib.request.urlopen(url).read()
  16.     text = data.decode("utf-8")
  17.     print(text)
  18.  
  19. print("1.전국 2.서울/경기 3.강원 4. 충북 5.충남 6.전북 7.전남 8.경북 9.경남 10.제주")
  20. select = int(input())
  21.  
  22. if select==1: code=108
  23. elif select==2: code=109
  24. elif select==3: code=105
  25. elif select==4: code=131
  26. elif select==5: code=133
  27. elif select==6: code=146
  28. elif select==7: code=156
  29. elif select==8: code=143
  30. elif select==9: code=159
  31. elif select==10: code=184
  32. else: code=108
  33. processor(code)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×