hjxdl 0.1.14__py3-none-any.whl → 0.1.15__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hdl/_version.py +2 -2
- hdl/utils/weather/__init__.py +0 -0
- hdl/utils/weather/weather.py +68 -0
- {hjxdl-0.1.14.dist-info → hjxdl-0.1.15.dist-info}/METADATA +1 -1
- {hjxdl-0.1.14.dist-info → hjxdl-0.1.15.dist-info}/RECORD +7 -5
- {hjxdl-0.1.14.dist-info → hjxdl-0.1.15.dist-info}/WHEEL +0 -0
- {hjxdl-0.1.14.dist-info → hjxdl-0.1.15.dist-info}/top_level.txt +0 -0
hdl/_version.py
CHANGED
File without changes
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import requests
|
2
|
+
from pathlib import Path
|
3
|
+
import os
|
4
|
+
import json
|
5
|
+
from bs4 import BeautifulSoup
|
6
|
+
|
7
|
+
|
8
|
+
def get_city_codes():
|
9
|
+
# with open('../../city.json', 'r', encoding='utf-8') as f:
|
10
|
+
# code_dic = eval(f.read())
|
11
|
+
# return code_dic
|
12
|
+
code_file = Path(__file__).resolve().parent.parent.parent \
|
13
|
+
/ "datasets" \
|
14
|
+
/ "city_code.json"
|
15
|
+
with code_file.open() as f:
|
16
|
+
code = json.load(f)
|
17
|
+
return code
|
18
|
+
|
19
|
+
|
20
|
+
def get_html(code):
|
21
|
+
weather_url = f'http://www.weather.com.cn/weather/{code}.shtml'
|
22
|
+
header = {
|
23
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36"}
|
24
|
+
print(weather_url)
|
25
|
+
resp = requests.get(url=weather_url, headers=header)
|
26
|
+
resp.encoding = 'utf-8'
|
27
|
+
return resp.text
|
28
|
+
|
29
|
+
|
30
|
+
def get_page_data(html):
|
31
|
+
soup = BeautifulSoup(html, 'html.parser')
|
32
|
+
weather_info = soup.find('div', id='7d')
|
33
|
+
seven_weather = weather_info.find('ul')
|
34
|
+
weather_list = seven_weather.find_all('li')
|
35
|
+
for weather in weather_list:
|
36
|
+
print('=' * 60)
|
37
|
+
print(weather.find('h1').get_text())
|
38
|
+
print('天气状况:', weather.find('p', class_='wea').get_text())
|
39
|
+
# 判断标签'p','tem'下是否有标签'span',以此判断是否有最高温
|
40
|
+
if weather.find('p', class_='tem').find('span'):
|
41
|
+
temp_high = weather.find('p', class_='tem').find('span').get_text()
|
42
|
+
else:
|
43
|
+
temp_high = '' # 最高温
|
44
|
+
temp_low = weather.find('p', class_='tem').find('i').get_text() # 最低温
|
45
|
+
print(f'天气温度:{temp_low}/{temp_high}')
|
46
|
+
win_list_tag = weather.find('p', class_='win').find('em').find_all('span')
|
47
|
+
win_list = []
|
48
|
+
for win in win_list_tag:
|
49
|
+
win_list.append(win.get('title'))
|
50
|
+
print('风向:', '-'.join(win_list))
|
51
|
+
print('风力:', weather.find('p', class_='win').find('i').get_text())
|
52
|
+
|
53
|
+
|
54
|
+
def main():
|
55
|
+
code_dic = get_city_codes()
|
56
|
+
print('=' * 60)
|
57
|
+
print('\t' * 5, '天气预报查询系统')
|
58
|
+
print('=' * 60)
|
59
|
+
city = input("请输入您要查询的城市:")
|
60
|
+
if city in code_dic:
|
61
|
+
html = get_html(code_dic[city]['AREAID'])
|
62
|
+
get_page_data(html)
|
63
|
+
else:
|
64
|
+
print('你要查询的地方不存在')
|
65
|
+
|
66
|
+
|
67
|
+
if __name__ == '__main__':
|
68
|
+
main()
|
@@ -1,5 +1,5 @@
|
|
1
1
|
hdl/__init__.py,sha256=5sZZNySv08wwfzJcSDssGTqUn9wlmDsR6R4XB8J8mFM,70
|
2
|
-
hdl/_version.py,sha256=
|
2
|
+
hdl/_version.py,sha256=ZKlmJ822TJ49YEqc2wCAMbrp81vFvzcFa9OTia84voM,413
|
3
3
|
hdl/args/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
hdl/args/loss_args.py,sha256=s7YzSdd7IjD24rZvvOrxLLFqMZQb9YylxKeyelSdrTk,70
|
5
5
|
hdl/controllers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -128,7 +128,9 @@ hdl/utils/llm/embs.py,sha256=Tf0FOYrOFZp7qQpEPiSCXzlgyHH0X9HVTUtsup74a9E,7174
|
|
128
128
|
hdl/utils/llm/extract.py,sha256=2sK_WJzmYIc8iuWaM9DA6Nw3_6q1O4lJ5pKpcZo-bBA,6512
|
129
129
|
hdl/utils/schedulers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
130
130
|
hdl/utils/schedulers/norm_lr.py,sha256=bDwCmdEK-WkgxQMFBiMuchv8Mm7C0-GZJ6usm-PQk14,4461
|
131
|
-
|
132
|
-
|
133
|
-
hjxdl-0.1.
|
134
|
-
hjxdl-0.1.
|
131
|
+
hdl/utils/weather/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
132
|
+
hdl/utils/weather/weather.py,sha256=H4f5wOojY28u_vtGkbPk_Nhe65R1Q9OZUPfVBY5AVAQ,2313
|
133
|
+
hjxdl-0.1.15.dist-info/METADATA,sha256=w7Iq4P0m1_G0ZDIzBCKGxm1dtHllYZklxQge8dM5SvE,543
|
134
|
+
hjxdl-0.1.15.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
|
135
|
+
hjxdl-0.1.15.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
|
136
|
+
hjxdl-0.1.15.dist-info/RECORD,,
|
File without changes
|
File without changes
|