hjxdl 0.1.14__py3-none-any.whl → 0.1.16__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 CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.1.14'
16
- __version_tuple__ = version_tuple = (0, 1, 14)
15
+ __version__ = version = '0.1.16'
16
+ __version_tuple__ = version_tuple = (0, 1, 16)
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
+ codes = json.load(f)
17
+ return codes
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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hjxdl
3
- Version: 0.1.14
3
+ Version: 0.1.16
4
4
  Summary: A collection of functions for Jupyter notebooks
5
5
  Home-page: https://github.com/huluxiaohuowa/hdl
6
6
  Author: Jianxing Hu
@@ -10,7 +10,9 @@ Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.6
12
12
  Description-Content-Type: text/markdown
13
- Requires-Dist: jupyfuncs
13
+ Requires-Dist: beautifulsoup4
14
+ Requires-Dist: openai
15
+ Requires-Dist: tqdm
14
16
 
15
17
  # DL framework by Jianxing
16
18
 
@@ -1,5 +1,5 @@
1
1
  hdl/__init__.py,sha256=5sZZNySv08wwfzJcSDssGTqUn9wlmDsR6R4XB8J8mFM,70
2
- hdl/_version.py,sha256=1w8OANeC0K0uOMBB6XWDhN49spC7ipRwXZnxjNMUZWU,413
2
+ hdl/_version.py,sha256=rA1LdDxj-8LJmPkCOu32O_el1jpvxISCr8X4yOogHgc,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
- hjxdl-0.1.14.dist-info/METADATA,sha256=zSqAbKEZutZyv5WQguUpas0Jm_nTHdBsdUyBpT6o8lQ,543
132
- hjxdl-0.1.14.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
133
- hjxdl-0.1.14.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
134
- hjxdl-0.1.14.dist-info/RECORD,,
131
+ hdl/utils/weather/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
132
+ hdl/utils/weather/weather.py,sha256=LiIgEX-XPZxltGWgrwJNXSvBuinF-VaBT3ohRWYDjPI,2315
133
+ hjxdl-0.1.16.dist-info/METADATA,sha256=8yEQaClAH1z9xw77MfSaZtEWhOjdW7NDRKAfbePA2lA,590
134
+ hjxdl-0.1.16.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
135
+ hjxdl-0.1.16.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
136
+ hjxdl-0.1.16.dist-info/RECORD,,
File without changes