Toggle navigation
Toggle navigation
This project
Loading...
Sign in
신승미
/
weatherClothing
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Seungmi
2020-12-10 02:08:58 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ae55646899c29fce02f7a88e7668b183747073d9
ae556468
1 parent
67c5eb09
수정본
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
5 deletions
weather_chat.py
weather_chat.py
View file @
ae55646
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
)
...
...
Please
register
or
login
to post a comment