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-09 23:59:21 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a563ab449b8d6972179fa3d84eef8c2a6083e730
a563ab44
1 parent
7c5de2ec
python 날씨 크롤링
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
weather_chat.py
weather_chat.py
0 → 100644
View file @
a563ab4
import
requests
from
bs4
import
BeautifulSoup
from
pprint
import
pprint
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
for
i
in
range
(
0
,
len
(
find_weather
)):
if
find_weather
[
i
]
==
','
:
weather_endIndex
=
i
break
weather
=
find_weather
[
0
:
weather_endIndex
]
notice
=
""
if
'비'
in
weather
:
notice
=
"비가 올 가능성이 있습니다. 우산을 챙기세요."
elif
'눈'
in
weather
:
notice
=
"눈이 올 가능성이 있습니다. 방한 용품을 챙기세요."
else
:
notice
=
"특이사항이 없습니다."
find_currenttemp
=
data1
.
find
(
'span'
,
{
'class'
:
'todaytemp'
})
.
text
currentTemp
=
int
(
find_currenttemp
)
print
(
'현재 온도: '
+
find_currenttemp
+
'도'
)
\ No newline at end of file
Please
register
or
login
to post a comment