Showing
1 changed file
with
31 additions
and
5 deletions
| 1 | import requests | 1 | import requests |
| 2 | +import sys | ||
| 2 | from bs4 import BeautifulSoup | 3 | from bs4 import BeautifulSoup |
| 3 | from pprint import pprint | 4 | from pprint import pprint |
| 4 | 5 | ||
| 6 | +data = sys.stdin.readline() | ||
| 7 | + | ||
| 5 | html = requests.get('https://search.naver.com/search.naver?query=날씨') | 8 | html = requests.get('https://search.naver.com/search.naver?query=날씨') |
| 6 | soup = BeautifulSoup(html.text, 'html.parser') | 9 | soup = BeautifulSoup(html.text, 'html.parser') |
| 7 | 10 | ||
| 8 | data1 = soup.find('div', {'class': 'weather_box'}) | 11 | data1 = soup.find('div', {'class': 'weather_box'}) |
| 9 | 12 | ||
| 13 | +# 위치 | ||
| 10 | address = data1.find('span', {'class': 'btn_select'}).text | 14 | address = data1.find('span', {'class': 'btn_select'}).text |
| 11 | 15 | ||
| 12 | 16 | ||
| 17 | +# 날씨 | ||
| 13 | find_weather= data1.find('p', {'class': 'cast_txt'}).text | 18 | find_weather= data1.find('p', {'class': 'cast_txt'}).text |
| 14 | 19 | ||
| 15 | weather_endIndex = 0 | 20 | weather_endIndex = 0 |
| ... | @@ -21,6 +26,30 @@ for i in range(0,len(find_weather)): | ... | @@ -21,6 +26,30 @@ for i in range(0,len(find_weather)): |
| 21 | 26 | ||
| 22 | weather = find_weather[0:weather_endIndex] | 27 | weather = find_weather[0:weather_endIndex] |
| 23 | 28 | ||
| 29 | +# 온도 | ||
| 30 | +find_currenttemp = data1.find('span', {'class':'todaytemp'}).text | ||
| 31 | +currentTemp = int(find_currenttemp) | ||
| 32 | + | ||
| 33 | +# 추천 옷차림새 | ||
| 34 | +if currentTemp >= 27: | ||
| 35 | + recDress = "나시티, 반바지, 민소매, 원피스" | ||
| 36 | +elif currentTemp >=23: | ||
| 37 | + recDress = "반팔, 얇은 셔츠, 얇은 긴팔, 반바지, 면바지" | ||
| 38 | +elif currentTemp >=20: | ||
| 39 | + recDress = "긴팔티, 가디건, 후드티, 면바지, 슬렉스, 스키니" | ||
| 40 | +elif currentTemp >=17: | ||
| 41 | + recDress = "니트, 가디건, 후드티, 맨투맨, 청바지, 면바지, 슬랙스, 원피스" | ||
| 42 | +elif currentTemp >= 12: | ||
| 43 | + recDress = "자켓, 셔츠, 가디건, 간절기 야상, 살색스타킹" | ||
| 44 | +elif currentTemp >=10: | ||
| 45 | + recDress = "트렌치코트, 간절기 야상, 니트" | ||
| 46 | +elif currentTemp >= 6: | ||
| 47 | + recDress = "코트, 가죽자켓" | ||
| 48 | +else: | ||
| 49 | + recDress = "겨울 옷(야상, 패딩, 방한용품)" | ||
| 50 | + | ||
| 51 | + | ||
| 52 | +# 특이사항(비/눈) | ||
| 24 | notice = "" | 53 | notice = "" |
| 25 | if '비' in weather: | 54 | if '비' in weather: |
| 26 | notice = "비가 올 가능성이 있습니다. 우산을 챙기세요." | 55 | notice = "비가 올 가능성이 있습니다. 우산을 챙기세요." |
| ... | @@ -29,8 +58,5 @@ elif '눈' in weather: | ... | @@ -29,8 +58,5 @@ elif '눈' in weather: |
| 29 | else: | 58 | else: |
| 30 | notice = "특이사항이 없습니다." | 59 | notice = "특이사항이 없습니다." |
| 31 | 60 | ||
| 32 | - | ||
| 33 | - | ||
| 34 | -find_currenttemp = data1.find('span', {'class':'todaytemp'}).text | ||
| 35 | -currentTemp = int(find_currenttemp) | ||
| 36 | -print('현재 온도: '+find_currenttemp+'도') | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 61 | +full = "현재 위치: "+address+'\n오늘의 온도: '+str(currentTemp)+'도'+'\n오늘의 날씨: '+weather+'\n추천 옷차림새: '+recDress+'\n특이사항: '+notice | ||
| 62 | +print(full) | ... | ... |
-
Please register or login to post a comment