Toggle navigation
Toggle navigation
This project
Loading...
Sign in
고원빈
/
weather
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Jihoon
2019-12-01 21:47:58 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
567ebd9a5b296bc572a920a980c65f45b6ba936c
567ebd9a
1 parent
fb2eb68c
1 excel file, 1 python file
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
0 deletions
area_code.xlsx
recommend_clothes.py
area_code.xlsx
0 → 100644
View file @
567ebd9
No preview for this file type
recommend_clothes.py
0 → 100644
View file @
567ebd9
from
bs4
import
BeautifulSoup
from
urllib.request
import
urlopen
import
openpyxl
import
datetime
# coding = utf-8
filename
=
"C://area_code.xlsx"
# area_code.xlsx
book
=
openpyxl
.
load_workbook
(
filename
)
sheet
=
book
.
worksheets
[
0
]
code
=
[]
for
cell
in
sheet
[
'E'
]:
code
.
append
(
cell
.
value
)
area
=
input
(
"읍/면/동을 입력(띄어쓰기 없이 입력 - 예:영통3동)
\n
"
)
col
=
code
.
index
(
area
)
area_code_index
=
'B'
+
str
(
col
+
1
)
area_code
=
sheet
[
area_code_index
]
.
value
#print(area_code)
now
=
datetime
.
datetime
.
now
()
nowDate
=
now
.
strftime
(
'
%
Y
%
m
%
d'
)
#20191201형태로 연월일 받음
#print(nowDate)
url
=
"http://newsky2.kma.go.kr/iros/RetrieveLifeIndexService3/getSensorytemLifeList?serviceKey=UwTMv516Y0zIgZCDqzdPtf1jmbv287
%2
BOn1kqxcZizw8
%2
Be5OV5UmIc09icqMqSpEMbHOiCWoPK
%2
BZVD
%2
Bjbc
%2
BwgBg
%3
D
%3
D&areaNo="
+
area_code
+
"&time="
+
nowDate
+
"03"
result
=
urlopen
(
url
)
html
=
result
.
read
()
soup
=
BeautifulSoup
(
html
,
'html.parser'
)
contents
=
soup
.
find
(
"date"
)
hours
=
[
"h3"
,
"h6"
,
"h9"
,
"h12"
,
"h15"
,
"h18"
,
"h21"
,
"h24"
]
# date의 시간으로부터 n시간 이후의 예측온도
sens_temper
=
[]
# 2019120103: 19년 12월 1일 새벽 3시 기준이므로 리스트에는 6시, 9시, ..., 익일 3시까지의 예측 체감온도가 저장됨.
#sens_temper[06시온도,09시온도,12시온도,15시온도,18시온도,21시온도,24시온도,익일03시온도]
for
i
in
range
(
0
,
len
(
hours
)):
temper
=
soup
.
find
(
hours
[
i
])
sens_temper
.
append
(
int
(
temper
.
text
))
if
i
<
2
:
print
(
"0"
+
str
(
int
(
hours
[
i
][
1
:])
+
3
)
+
"시:"
,
temper
.
text
+
"°C"
)
elif
i
==
7
:
print
(
"익일 03시:"
,
temper
.
text
+
"°C"
)
else
:
print
(
str
(
int
(
hours
[
i
][
1
:])
+
3
)
+
"시:"
,
temper
.
text
+
"°C"
)
if
max
(
sens_temper
)
<=
5
:
if
min
(
sens_temper
)
>=
-
5
and
min
(
sens_temper
)
<=
0
:
print
(
"패딩, 겨울야상, 양털자켓, 폴라티, 니트, 기모바지"
)
print
(
"쌀쌀한 날씨입니다. 생각보다 추워요!"
)
elif
min
(
sens_temper
)
<
-
5
:
print
(
"패딩, 겨울야상, 양털자켓, 폴라티, 니트, 기모바지"
)
print
(
"마스크, 목도리, 장갑을 착용하세요!"
)
if
min
(
sens_temper
)
<
-
10
:
print
(
"외출을 자제하는 것이 좋겠습니다!"
)
elif
min
(
sens_temper
)
>
0
:
print
(
"패딩, 겨울야상, 양털자켓, 폴라티, 니트, 기모바지, 스타킹"
)
print
(
"0도를 웃도는 날씨네요. 외투 안에는 가벼운 옷을 추천해요!"
)
if
max
(
sens_temper
)
>=
6
and
max
(
sens_temper
)
<=
9
:
print
(
"코트, 가죽자켓, 맨투맨, 티셔츠(사계절), 바지(사계절)"
)
if
min
(
sens_temper
)
<
3
:
print
(
"일교차에 유의하세요! 추위에 약한 분들은 외투 하나 더 챙기세요!"
)
elif
max
(
sens_temper
)
>=
10
and
max
(
sens_temper
)
<=
11
:
print
(
"트렌치코트, 간절기 야상, 후드티, 여러겹 레이어드"
)
if
min
(
sens_temper
)
<
5
:
print
(
"일교차에 유의하세요! 추위에 약한 분들은 외투 하나 더 챙기세요!"
)
elif
max
(
sens_temper
)
>=
12
and
max
(
sens_temper
)
<=
16
:
print
(
"자켓, 셔츠, 가디건, 후드(사계절)"
)
if
min
(
sens_temper
)
<
6
:
print
(
"일교차에 유의하세요! 추위에 약한 분들은 외투 하나 더 챙기세요!"
)
elif
max
(
sens_temper
)
>=
17
and
max
(
sens_temper
)
<=
19
:
print
(
"가디건, 니트, 맨투맨, 후드티, 면바지, 슬랙스, 원피스"
)
if
min
(
sens_temper
)
<
9
:
print
(
"일교차에 유의하세요! 얇은 외투 챙겨가세요!"
)
elif
max
(
sens_temper
)
>=
20
and
max
(
sens_temper
)
<=
22
:
print
(
"긴팔티, 후드티, 면바지, 슬랙스"
)
if
min
(
sens_temper
)
<
11
:
print
(
"일교차에 유의하세요! 얇은 외투 챙겨가세요!"
)
elif
max
(
sens_temper
)
>=
23
and
max
(
sens_temper
)
<=
26
:
print
(
"반팔티, 얇은 셔츠, 얇은 긴팔티, 반바지, 면바지"
)
Please
register
or
login
to post a comment