Seungmi

수정본

import requests
import sys
from bs4 import BeautifulSoup
from pprint import pprint
data = sys.stdin.readline()
html = requests.get('https://search.naver.com/search.naver?query=날씨')
soup = BeautifulSoup(html.text, 'html.parser')
data1 = soup.find('div', {'class': 'weather_box'})
# 위치
address = data1.find('span', {'class': 'btn_select'}).text
# 날씨
find_weather= data1.find('p', {'class': 'cast_txt'}).text
weather_endIndex = 0
......@@ -21,6 +26,30 @@ for i in range(0,len(find_weather)):
weather = find_weather[0:weather_endIndex]
# 온도
find_currenttemp = data1.find('span', {'class':'todaytemp'}).text
currentTemp = int(find_currenttemp)
# 추천 옷차림새
if currentTemp >= 27:
recDress = "나시티, 반바지, 민소매, 원피스"
elif currentTemp >=23:
recDress = "반팔, 얇은 셔츠, 얇은 긴팔, 반바지, 면바지"
elif currentTemp >=20:
recDress = "긴팔티, 가디건, 후드티, 면바지, 슬렉스, 스키니"
elif currentTemp >=17:
recDress = "니트, 가디건, 후드티, 맨투맨, 청바지, 면바지, 슬랙스, 원피스"
elif currentTemp >= 12:
recDress = "자켓, 셔츠, 가디건, 간절기 야상, 살색스타킹"
elif currentTemp >=10:
recDress = "트렌치코트, 간절기 야상, 니트"
elif currentTemp >= 6:
recDress = "코트, 가죽자켓"
else:
recDress = "겨울 옷(야상, 패딩, 방한용품)"
# 특이사항(비/눈)
notice = ""
if '비' in weather:
notice = "비가 올 가능성이 있습니다. 우산을 챙기세요."
......@@ -29,8 +58,5 @@ elif '눈' in weather:
else:
notice = "특이사항이 없습니다."
find_currenttemp = data1.find('span', {'class':'todaytemp'}).text
currentTemp = int(find_currenttemp)
print('현재 온도: '+find_currenttemp+'도')
\ No newline at end of file
full = "현재 위치: "+address+'\n오늘의 온도: '+str(currentTemp)+'도'+'\n오늘의 날씨: '+weather+'\n추천 옷차림새: '+recDress+'\n특이사항: '+notice
print(full)
......