XMWAI 0.4.6__py3-none-any.whl → 0.4.8__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.
Potentially problematic release.
This version of XMWAI might be problematic. Click here for more details.
- XMWAI/__init__.py +4 -3
- XMWAI/assets/__init__.py +0 -0
- XMWAI/assets/like.png +0 -0
- XMWAI/effects_core.py +205 -0
- XMWAI/fortune_core.py +527 -0
- {xmwai-0.4.6.dist-info → xmwai-0.4.8.dist-info}/METADATA +2 -1
- {xmwai-0.4.6.dist-info → xmwai-0.4.8.dist-info}/RECORD +10 -15
- XMWAI/assets/1.png +0 -0
- XMWAI/assets/g.png +0 -0
- XMWAI/assets/h.png +0 -0
- XMWAI/assets/l.png +0 -0
- XMWAI/assets/m.png +0 -0
- XMWAI/assets/s.png +0 -0
- XMWAI/assets/t.png +0 -0
- XMWAI/assets//321/205/342/225/233/320/276/321/210/342/225/234/320/277/321/211/320/253/320/225/321/211/342/225/227/320/241.ttf +0 -0
- XMWAI/snake_core.py +0 -595
- {xmwai-0.4.6.dist-info → xmwai-0.4.8.dist-info}/WHEEL +0 -0
- {xmwai-0.4.6.dist-info → xmwai-0.4.8.dist-info}/licenses/LICENSE.txt +0 -0
- {xmwai-0.4.6.dist-info → xmwai-0.4.8.dist-info}/top_level.txt +0 -0
XMWAI/fortune_core.py
ADDED
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import re
|
|
3
|
+
import os
|
|
4
|
+
from bs4 import BeautifulSoup
|
|
5
|
+
import urllib.parse
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def fate(constellation):
|
|
9
|
+
dict_ = {"水瓶座": "aquarius",
|
|
10
|
+
"双鱼座": "pisces",
|
|
11
|
+
"白羊座": "aries",
|
|
12
|
+
"金牛座": "taurus",
|
|
13
|
+
"双子座": "gemini",
|
|
14
|
+
"巨蟹座": "cancer",
|
|
15
|
+
"狮子座": "leo",
|
|
16
|
+
"处女座": "virgo",
|
|
17
|
+
"天秤座": "libra",
|
|
18
|
+
"天蝎座": "scorpio",
|
|
19
|
+
"射手座": "sagittarius",
|
|
20
|
+
"摩羯座": "capricorn"}
|
|
21
|
+
|
|
22
|
+
url = "https://www.xzw.com/fortune/" + dict_[constellation] + "/"
|
|
23
|
+
headers = {
|
|
24
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
try:
|
|
28
|
+
response = requests.get(url, headers=headers, timeout=10)
|
|
29
|
+
response.encoding = 'utf-8'
|
|
30
|
+
content = response.text
|
|
31
|
+
except Exception as e:
|
|
32
|
+
print(f"获取数据失败: {e}")
|
|
33
|
+
return get_default_data()
|
|
34
|
+
|
|
35
|
+
# 使用BeautifulSoup解析HTML
|
|
36
|
+
soup = BeautifulSoup(content, 'html.parser')
|
|
37
|
+
|
|
38
|
+
# 获取详细运势数据
|
|
39
|
+
fortune_data = {}
|
|
40
|
+
indices = {}
|
|
41
|
+
|
|
42
|
+
# 提取综合运势评分(星星数量)
|
|
43
|
+
fortune_data['综合运势评分'] = 3 # 默认值
|
|
44
|
+
|
|
45
|
+
try:
|
|
46
|
+
# 方法1:从星星评分条提取 - 最准确的方法
|
|
47
|
+
star_bar = soup.select_one('span.star_m.star_blue em')
|
|
48
|
+
if star_bar:
|
|
49
|
+
style_width = star_bar.get('style', '')
|
|
50
|
+
width_match = re.search(r'width:\s*(\d+)px', style_width)
|
|
51
|
+
if width_match:
|
|
52
|
+
width_px = int(width_match.group(1))
|
|
53
|
+
# 每颗星20px,总宽度100px(5星)
|
|
54
|
+
stars_count = round(width_px / 20)
|
|
55
|
+
if 1 <= stars_count <= 5:
|
|
56
|
+
fortune_data['综合运势评分'] = stars_count
|
|
57
|
+
|
|
58
|
+
# 方法2:从图表数据中提取 - 备用方法
|
|
59
|
+
if fortune_data['综合运势评分'] == 3:
|
|
60
|
+
# 查找图表中的综合指数
|
|
61
|
+
chart_data_match = re.search(
|
|
62
|
+
r'"综合指数".*?data:\s*\[(.*?)\]', str(soup))
|
|
63
|
+
if chart_data_match:
|
|
64
|
+
data_str = chart_data_match.group(1)
|
|
65
|
+
numbers = re.findall(r'(\d+(?:\.\d+)?)', data_str)
|
|
66
|
+
if numbers:
|
|
67
|
+
# 取最新的综合指数
|
|
68
|
+
latest_score = float(numbers[-1])
|
|
69
|
+
# 将0-5分转换为1-5星
|
|
70
|
+
stars_count = max(1, min(5, round(latest_score)))
|
|
71
|
+
fortune_data['综合运势评分'] = stars_count
|
|
72
|
+
|
|
73
|
+
# 方法3:从其他星星评分元素中提取
|
|
74
|
+
if fortune_data['综合运势评分'] == 3:
|
|
75
|
+
# 查找其他可能的星星评分
|
|
76
|
+
star_elements = soup.find_all(
|
|
77
|
+
class_=re.compile(r'star_m|star_rating'))
|
|
78
|
+
for elem in star_elements:
|
|
79
|
+
em_elem = elem.find('em')
|
|
80
|
+
if em_elem and em_elem.get('style'):
|
|
81
|
+
width_match = re.search(
|
|
82
|
+
r'width:\s*(\d+)px', em_elem.get('style', ''))
|
|
83
|
+
if width_match:
|
|
84
|
+
width_px = int(width_match.group(1))
|
|
85
|
+
stars_count = round(width_px / 20)
|
|
86
|
+
if 1 <= stars_count <= 5:
|
|
87
|
+
fortune_data['综合运势评分'] = stars_count
|
|
88
|
+
break
|
|
89
|
+
|
|
90
|
+
except Exception as e:
|
|
91
|
+
print(f"提取星星评分失败: {e}")
|
|
92
|
+
fortune_data['综合运势评分'] = 3
|
|
93
|
+
|
|
94
|
+
# 提取各项指数 - 更精确的正则表达式
|
|
95
|
+
text_content = soup.get_text()
|
|
96
|
+
|
|
97
|
+
# 健康指数
|
|
98
|
+
health_patterns = [
|
|
99
|
+
r'健康指数[::]\s*(\d+)%?',
|
|
100
|
+
r'健康.*?\s*(\d+)%?',
|
|
101
|
+
r'健康.*?指数[::]\s*(\d+)'
|
|
102
|
+
]
|
|
103
|
+
indices['健康指数'] = extract_number(text_content, health_patterns, 75)
|
|
104
|
+
|
|
105
|
+
# 商谈指数
|
|
106
|
+
discuss_patterns = [
|
|
107
|
+
r'商谈指数[::]\s*(\d+)%?',
|
|
108
|
+
r'商谈.*?\s*(\d+)%?',
|
|
109
|
+
r'商谈.*?指数[::]\s*(\d+)'
|
|
110
|
+
]
|
|
111
|
+
indices['商谈指数'] = extract_number(text_content, discuss_patterns, 70)
|
|
112
|
+
|
|
113
|
+
# 幸运颜色
|
|
114
|
+
# 幸运颜色 - 修复提取逻辑,避免包含"幸运数字"
|
|
115
|
+
color_patterns = [
|
|
116
|
+
r'幸运颜色[::]\s*([\u4e00-\u9fa5]+?)(?:幸运数字|$)', # 只提取颜色,到"幸运数字"为止
|
|
117
|
+
r'幸运色[::]\s*([\u4e00-\u9fa5]+?)(?:幸运数字|$)', # 只提取颜色,到"幸运数字"为止
|
|
118
|
+
r'颜色.*?幸运[::]\s*([\u4e00-\u9fa5]+?)(?:幸运数字|$)' # 只提取颜色,到"幸运数字"为止
|
|
119
|
+
]
|
|
120
|
+
indices['幸运颜色'] = extract_text(text_content, color_patterns, '蓝色')
|
|
121
|
+
|
|
122
|
+
# 幸运数字
|
|
123
|
+
number_patterns = [
|
|
124
|
+
r'幸运数字[::]\s*(\d+)',
|
|
125
|
+
r'幸运.*?数字[::]\s*(\d+)',
|
|
126
|
+
r'数字.*?幸运[::]\s*(\d+)'
|
|
127
|
+
]
|
|
128
|
+
indices['幸运数字'] = extract_number(text_content, number_patterns, 7)
|
|
129
|
+
|
|
130
|
+
# 获取今日综合运势解读
|
|
131
|
+
comprehensive_text = extract_fortune_description(soup, text_content)
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
'indices': indices,
|
|
135
|
+
'comprehensive_text': comprehensive_text,
|
|
136
|
+
'stars': fortune_data['综合运势评分']
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def extract_number(text, patterns, default):
|
|
141
|
+
"""从文本中提取数字"""
|
|
142
|
+
for pattern in patterns:
|
|
143
|
+
match = re.search(pattern, text, re.IGNORECASE)
|
|
144
|
+
if match:
|
|
145
|
+
try:
|
|
146
|
+
return int(match.group(1))
|
|
147
|
+
except:
|
|
148
|
+
continue
|
|
149
|
+
return default
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def extract_text(text, patterns, default):
|
|
153
|
+
"""从文本中提取文本"""
|
|
154
|
+
for pattern in patterns:
|
|
155
|
+
match = re.search(pattern, text, re.IGNORECASE)
|
|
156
|
+
if match:
|
|
157
|
+
return match.group(1).strip()
|
|
158
|
+
return default
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def extract_fortune_description(soup, text_content):
|
|
162
|
+
"""提取运势描述"""
|
|
163
|
+
try:
|
|
164
|
+
# 尝试多种方式提取运势描述
|
|
165
|
+
description = ""
|
|
166
|
+
|
|
167
|
+
# 方式1:查找综合运势区域
|
|
168
|
+
fortune_section = soup.find('div', class_='c_cont')
|
|
169
|
+
if fortune_section:
|
|
170
|
+
desc_text = fortune_section.find('span')
|
|
171
|
+
if desc_text:
|
|
172
|
+
description = desc_text.get_text().strip()
|
|
173
|
+
|
|
174
|
+
# 方式2:使用正则表达式
|
|
175
|
+
if not description:
|
|
176
|
+
patterns = [
|
|
177
|
+
r'综合运势</strong><span>(.*?)</span>',
|
|
178
|
+
r'整体运势[::]?(.*?)[。!?]',
|
|
179
|
+
r'今日运势[::]?(.*?)[。!?]',
|
|
180
|
+
r'今日.*?运势[::]?(.*?)[。!?]'
|
|
181
|
+
]
|
|
182
|
+
|
|
183
|
+
for pattern in patterns:
|
|
184
|
+
match = re.search(pattern, str(soup), re.DOTALL)
|
|
185
|
+
if match:
|
|
186
|
+
description = match.group(1).strip()
|
|
187
|
+
break
|
|
188
|
+
|
|
189
|
+
# 清理HTML标签和多余空格
|
|
190
|
+
if description:
|
|
191
|
+
description = re.sub(r'<[^>]+>', '', description)
|
|
192
|
+
description = re.sub(r'\s+', ' ', description)
|
|
193
|
+
|
|
194
|
+
# 彻底清理所有可能的干扰信息 - 使用更通用的正则表达式
|
|
195
|
+
# 匹配"星"后面跟着任意字符(包括字母、数字、特殊符号)再跟着"座"的模式
|
|
196
|
+
description = re.sub(
|
|
197
|
+
r'星[^\u4e00-\u9fa5]*座[^\u4e00-\u9fa5]*屋?', '', description)
|
|
198
|
+
|
|
199
|
+
# 清理单独的"星"字后面跟着非中文字符
|
|
200
|
+
description = re.sub(r'星[^\u4e00-\u9fa5\w]*', '', description)
|
|
201
|
+
|
|
202
|
+
# 清理"座"字后面跟着非中文字符
|
|
203
|
+
description = re.sub(r'座[^\u4e00-\u9fa5\w]*', '', description)
|
|
204
|
+
|
|
205
|
+
# 清理"屋"字前面可能有的干扰字符
|
|
206
|
+
description = re.sub(r'[^\u4e00-\u9fa5\w]*屋', '', description)
|
|
207
|
+
|
|
208
|
+
# 清理残留的英文、数字、特殊字符组合
|
|
209
|
+
description = re.sub(r'[a-zA-Z0-9]+$', '', description)
|
|
210
|
+
|
|
211
|
+
description = description.strip()
|
|
212
|
+
|
|
213
|
+
if len(description) > 10: # 确保有有效内容
|
|
214
|
+
return description
|
|
215
|
+
|
|
216
|
+
# 方式3:从页面主要内容中提取
|
|
217
|
+
if not description:
|
|
218
|
+
main_content = soup.find('div', class_='main')
|
|
219
|
+
if main_content:
|
|
220
|
+
paragraphs = main_content.find_all('p')
|
|
221
|
+
for p in paragraphs:
|
|
222
|
+
text = p.get_text().strip()
|
|
223
|
+
if len(text) > 20 and '运势' in text:
|
|
224
|
+
description = text
|
|
225
|
+
break
|
|
226
|
+
|
|
227
|
+
return description if description else "今日运势平稳,保持积极心态,顺其自然即可。"
|
|
228
|
+
|
|
229
|
+
except Exception as e:
|
|
230
|
+
print(f"提取运势描述失败: {e}")
|
|
231
|
+
return "今日运势平稳,保持积极心态,顺其自然即可。"
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def get_default_data():
|
|
235
|
+
"""返回默认数据"""
|
|
236
|
+
return {
|
|
237
|
+
'indices': {
|
|
238
|
+
'健康指数': 75,
|
|
239
|
+
'商谈指数': 70,
|
|
240
|
+
'幸运颜色': '蓝色',
|
|
241
|
+
'幸运数字': 7
|
|
242
|
+
},
|
|
243
|
+
'comprehensive_text': "今日运势平稳,保持积极心态,顺其自然即可。",
|
|
244
|
+
'stars': 3
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def download_image(url, save_path):
|
|
249
|
+
"""下载图片到本地"""
|
|
250
|
+
try:
|
|
251
|
+
headers = {
|
|
252
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
|
|
253
|
+
}
|
|
254
|
+
response = requests.get(url, timeout=15, headers=headers)
|
|
255
|
+
response.raise_for_status()
|
|
256
|
+
|
|
257
|
+
if len(response.content) > 1024:
|
|
258
|
+
with open(save_path, 'wb') as f:
|
|
259
|
+
f.write(response.content)
|
|
260
|
+
return True
|
|
261
|
+
except Exception as e:
|
|
262
|
+
print(f"下载图片失败: {url} - {e}")
|
|
263
|
+
return False
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def web(avatar, zodiac, trait, fortune_data):
|
|
267
|
+
output_dir = "output"
|
|
268
|
+
if not os.path.exists(output_dir):
|
|
269
|
+
os.makedirs(output_dir)
|
|
270
|
+
|
|
271
|
+
# 修复路径分隔符问题
|
|
272
|
+
avatar_relative_path = avatar.replace('\\', '/')
|
|
273
|
+
if not avatar_relative_path.startswith('../'):
|
|
274
|
+
avatar_relative_path = '../' + avatar_relative_path
|
|
275
|
+
|
|
276
|
+
# 获取运势数据
|
|
277
|
+
indices = fortune_data.get('indices', {})
|
|
278
|
+
comprehensive_text = fortune_data.get('comprehensive_text', trait)
|
|
279
|
+
stars = fortune_data.get('stars', 3)
|
|
280
|
+
|
|
281
|
+
# 生成星星图标
|
|
282
|
+
star_icons = '⭐' * stars + '☆' * (5 - stars)
|
|
283
|
+
|
|
284
|
+
# 完整的HTML页面
|
|
285
|
+
html_code = f"""<!DOCTYPE html>
|
|
286
|
+
<html lang="zh-CN">
|
|
287
|
+
<head>
|
|
288
|
+
<meta charset="UTF-8">
|
|
289
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
290
|
+
<title>今日运势 - {zodiac}</title>
|
|
291
|
+
<script src="https://cdn.tailwindcss.com"></script>
|
|
292
|
+
<style>
|
|
293
|
+
body {{
|
|
294
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
295
|
+
min-height: 100vh;
|
|
296
|
+
display: flex;
|
|
297
|
+
align-items: center;
|
|
298
|
+
justify-content: center;
|
|
299
|
+
padding: 20px;
|
|
300
|
+
font-family: 'Arial', sans-serif;
|
|
301
|
+
}}
|
|
302
|
+
|
|
303
|
+
.fortune-container {{
|
|
304
|
+
background: rgba(255, 255, 255, 0.1);
|
|
305
|
+
backdrop-filter: blur(10px);
|
|
306
|
+
border-radius: 20px;
|
|
307
|
+
padding: 40px;
|
|
308
|
+
max-width: 600px;
|
|
309
|
+
width: 100%;
|
|
310
|
+
box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
|
|
311
|
+
border: 1px solid rgba(255, 255, 255, 0.18);
|
|
312
|
+
color: white;
|
|
313
|
+
}}
|
|
314
|
+
|
|
315
|
+
.zodiac-header {{
|
|
316
|
+
text-align: center;
|
|
317
|
+
margin-bottom: 30px;
|
|
318
|
+
}}
|
|
319
|
+
|
|
320
|
+
.zodiac-avatar {{
|
|
321
|
+
width: 100px;
|
|
322
|
+
height: 100px;
|
|
323
|
+
border-radius: 50%;
|
|
324
|
+
margin: 0 auto 20px;
|
|
325
|
+
background: rgba(255, 255, 255, 0.2);
|
|
326
|
+
display: flex;
|
|
327
|
+
align-items: center;
|
|
328
|
+
justify-content: center;
|
|
329
|
+
border: 3px solid rgba(255, 255, 255, 0.3);
|
|
330
|
+
}}
|
|
331
|
+
|
|
332
|
+
.zodiac-avatar img {{
|
|
333
|
+
width: 80px;
|
|
334
|
+
height: 80px;
|
|
335
|
+
border-radius: 50%;
|
|
336
|
+
}}
|
|
337
|
+
|
|
338
|
+
.stars-display {{
|
|
339
|
+
text-align: center;
|
|
340
|
+
margin-bottom: 25px;
|
|
341
|
+
background: rgba(255, 255, 255, 0.1);
|
|
342
|
+
padding: 20px;
|
|
343
|
+
border-radius: 15px;
|
|
344
|
+
}}
|
|
345
|
+
|
|
346
|
+
.stars {{
|
|
347
|
+
font-size: 28px;
|
|
348
|
+
margin: 10px 0;
|
|
349
|
+
letter-spacing: 2px;
|
|
350
|
+
}}
|
|
351
|
+
|
|
352
|
+
.score {{
|
|
353
|
+
font-size: 20px;
|
|
354
|
+
font-weight: bold;
|
|
355
|
+
color: #ffd700;
|
|
356
|
+
margin-top: 5px;
|
|
357
|
+
}}
|
|
358
|
+
|
|
359
|
+
.indices-grid {{
|
|
360
|
+
display: grid;
|
|
361
|
+
grid-template-columns: 1fr 1fr;
|
|
362
|
+
gap: 15px;
|
|
363
|
+
margin-bottom: 25px;
|
|
364
|
+
}}
|
|
365
|
+
|
|
366
|
+
.index-item {{
|
|
367
|
+
background: rgba(255, 255, 255, 0.15);
|
|
368
|
+
padding: 15px;
|
|
369
|
+
border-radius: 12px;
|
|
370
|
+
text-align: center;
|
|
371
|
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
372
|
+
transition: transform 0.3s ease;
|
|
373
|
+
}}
|
|
374
|
+
|
|
375
|
+
.index-item:hover {{
|
|
376
|
+
transform: translateY(-2px);
|
|
377
|
+
background: rgba(255, 255, 255, 0.2);
|
|
378
|
+
}}
|
|
379
|
+
|
|
380
|
+
.label {{
|
|
381
|
+
display: block;
|
|
382
|
+
font-size: 14px;
|
|
383
|
+
margin-bottom: 8px;
|
|
384
|
+
opacity: 0.8;
|
|
385
|
+
font-weight: 500;
|
|
386
|
+
}}
|
|
387
|
+
|
|
388
|
+
.value {{
|
|
389
|
+
font-size: 18px;
|
|
390
|
+
font-weight: bold;
|
|
391
|
+
color: #fff;
|
|
392
|
+
}}
|
|
393
|
+
|
|
394
|
+
.color-badge {{
|
|
395
|
+
padding: 4px 12px;
|
|
396
|
+
border-radius: 20px;
|
|
397
|
+
color: white;
|
|
398
|
+
font-size: 14px;
|
|
399
|
+
display: inline-block;
|
|
400
|
+
}}
|
|
401
|
+
|
|
402
|
+
.comprehensive-section {{
|
|
403
|
+
background: rgba(255, 255, 255, 0.15);
|
|
404
|
+
padding: 25px;
|
|
405
|
+
border-radius: 15px;
|
|
406
|
+
margin-top: 20px;
|
|
407
|
+
border-left: 4px solid #ffd700;
|
|
408
|
+
}}
|
|
409
|
+
|
|
410
|
+
.comprehensive-section h3 {{
|
|
411
|
+
color: #ffd700;
|
|
412
|
+
font-size: 20px;
|
|
413
|
+
margin-bottom: 15px;
|
|
414
|
+
font-weight: bold;
|
|
415
|
+
}}
|
|
416
|
+
|
|
417
|
+
.comprehensive-text {{
|
|
418
|
+
font-size: 16px;
|
|
419
|
+
line-height: 1.8;
|
|
420
|
+
text-align: justify;
|
|
421
|
+
opacity: 0.95;
|
|
422
|
+
}}
|
|
423
|
+
|
|
424
|
+
.footer {{
|
|
425
|
+
text-align: center;
|
|
426
|
+
margin-top: 30px;
|
|
427
|
+
font-size: 14px;
|
|
428
|
+
opacity: 0.7;
|
|
429
|
+
font-style: italic;
|
|
430
|
+
}}
|
|
431
|
+
</style>
|
|
432
|
+
</head>
|
|
433
|
+
<body>
|
|
434
|
+
<div class="fortune-container">
|
|
435
|
+
<div class="zodiac-header">
|
|
436
|
+
<div class="zodiac-avatar">
|
|
437
|
+
<img src="{avatar_relative_path}" alt="{zodiac}">
|
|
438
|
+
</div>
|
|
439
|
+
<h1 style="font-size: 32px; margin-bottom: 10px;">{zodiac}</h1>
|
|
440
|
+
<p style="font-size: 18px; opacity: 0.8;">{trait}</p>
|
|
441
|
+
</div>
|
|
442
|
+
|
|
443
|
+
<div class="stars-display">
|
|
444
|
+
<h3 style="font-size: 22px; margin-bottom: 10px;">✨ 今日综合运势 ✨</h3>
|
|
445
|
+
<div class="stars">{star_icons}</div>
|
|
446
|
+
<div class="score">{stars}/5 星</div>
|
|
447
|
+
</div>
|
|
448
|
+
|
|
449
|
+
<div class="indices-grid">
|
|
450
|
+
<div class="index-item">
|
|
451
|
+
<span class="label">💗 健康指数</span>
|
|
452
|
+
<span class="value">{indices.get('健康指数', 75)}%</span>
|
|
453
|
+
</div>
|
|
454
|
+
<div class="index-item">
|
|
455
|
+
<span class="label">💬 商谈指数</span>
|
|
456
|
+
<span class="value">{indices.get('商谈指数', 70)}%</span>
|
|
457
|
+
</div>
|
|
458
|
+
<div class="index-item">
|
|
459
|
+
<span class="label">🎨 幸运颜色</span>
|
|
460
|
+
<span class="value">
|
|
461
|
+
<span class="color-badge" style="background-color: {indices.get('幸运颜色', '蓝色')}">
|
|
462
|
+
{indices.get('幸运颜色', '蓝色')}
|
|
463
|
+
</span>
|
|
464
|
+
</span>
|
|
465
|
+
</div>
|
|
466
|
+
<div class="index-item">
|
|
467
|
+
<span class="label">🔢 幸运数字</span>
|
|
468
|
+
<span class="value">{indices.get('幸运数字', 7)}</span>
|
|
469
|
+
</div>
|
|
470
|
+
</div>
|
|
471
|
+
|
|
472
|
+
<div class="comprehensive-section">
|
|
473
|
+
<h3>📊 今日综合运势解读</h3>
|
|
474
|
+
<div class="comprehensive-text">
|
|
475
|
+
{comprehensive_text}
|
|
476
|
+
</div>
|
|
477
|
+
</div>
|
|
478
|
+
|
|
479
|
+
<div class="footer">
|
|
480
|
+
✨ 星座运势仅供参考,保持积极心态最重要 ✨
|
|
481
|
+
</div>
|
|
482
|
+
</div>
|
|
483
|
+
</body>
|
|
484
|
+
</html>"""
|
|
485
|
+
|
|
486
|
+
output_path = os.path.join(output_dir, f"{zodiac}.html")
|
|
487
|
+
with open(output_path, "w", encoding="utf-8") as f:
|
|
488
|
+
f.write(html_code)
|
|
489
|
+
|
|
490
|
+
print(f"✅ 已生成网页: {output_path}")
|
|
491
|
+
|
|
492
|
+
try:
|
|
493
|
+
os.startfile(output_path)
|
|
494
|
+
except:
|
|
495
|
+
try:
|
|
496
|
+
os.system(f"start {output_path}")
|
|
497
|
+
except:
|
|
498
|
+
print(f"请手动打开: {output_path}")
|
|
499
|
+
|
|
500
|
+
# 向后兼容的原始函数
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
def fate_old(constellation):
|
|
504
|
+
dict_ = {"水瓶座": "aquarius",
|
|
505
|
+
"双鱼座": "pisces",
|
|
506
|
+
"白羊座": "aries",
|
|
507
|
+
"金牛座": "taurus",
|
|
508
|
+
"双子座": "gemini",
|
|
509
|
+
"巨蟹座": "cancer",
|
|
510
|
+
"狮子座": "leo",
|
|
511
|
+
"处女座": "virgo",
|
|
512
|
+
"天秤座": "libra",
|
|
513
|
+
"天蝎座": "scorpio",
|
|
514
|
+
"射手座": "sagittarius",
|
|
515
|
+
"摩羯座": "capricorn"}
|
|
516
|
+
|
|
517
|
+
url = "https://www.xzw.com/fortune/" + dict_[constellation] + "/"
|
|
518
|
+
response = requests.get(url)
|
|
519
|
+
response.encoding = 'utf-8'
|
|
520
|
+
content = response.text
|
|
521
|
+
|
|
522
|
+
try:
|
|
523
|
+
detail_comprehensive = re.findall(
|
|
524
|
+
'综合运势</strong><span>(.*?)</span>', content)[0]
|
|
525
|
+
except:
|
|
526
|
+
detail_comprehensive = "暂无数据"
|
|
527
|
+
return detail_comprehensive
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: XMWAI
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.8
|
|
4
4
|
Summary: Small code King AI related library
|
|
5
5
|
Home-page: https://github.com/Tonykai88/XMWAI.git
|
|
6
6
|
Author: pydevelopment
|
|
@@ -18,6 +18,7 @@ Requires-Dist: numpy>=1.26.0
|
|
|
18
18
|
Requires-Dist: flask>=3.1.0
|
|
19
19
|
Requires-Dist: pyecharts>=2.0.8
|
|
20
20
|
Requires-Dist: cvzone>=1.6.1
|
|
21
|
+
Requires-Dist: beautifulsoup4>=4.13.4
|
|
21
22
|
Dynamic: author
|
|
22
23
|
Dynamic: author-email
|
|
23
24
|
Dynamic: classifier
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
XMWAI/__init__.py,sha256=
|
|
1
|
+
XMWAI/__init__.py,sha256=feCsI7uB0dSe6wRdXRruYfiIYIWIznnESaqBclnl2D8,1320
|
|
2
2
|
XMWAI/bomb_core.py,sha256=h2ZPH3SuoG2L_XOf1dcK8p3lhw5QzhneWl2yMLj1RiU,1819
|
|
3
3
|
XMWAI/core.py,sha256=rOXj7FnewSdnzBcFLjpnBtrOTCsvMfiycIcdPDagxho,10012
|
|
4
|
+
XMWAI/effects_core.py,sha256=QDcU08HZ6ODLRD7l_wZ2M_UtC6Iayg2vt3oFcY6bsHk,5915
|
|
5
|
+
XMWAI/fortune_core.py,sha256=s-QlM48s6-0LGof9Jltt-rtbV9thQ8mzNYh8G9d5nPk,18046
|
|
4
6
|
XMWAI/idiom_core.py,sha256=yU-VHhqqoutVm6GVikcjL3m9yuB1hUsFBpPYvwY4n5g,1689
|
|
5
7
|
XMWAI/magic_core.py,sha256=Ms4b12PJ8rjsmceg1VUqWCWx2ebvdhLp4sIF6K_Vaok,3491
|
|
6
|
-
XMWAI/snake_core.py,sha256=f22mPKUxcQYVMiQeNEGAOD5M1ex2jemIQmuwxJdy26c,24038
|
|
7
8
|
XMWAI/trial_class.py,sha256=fPsl7BZvhzch2FOIG4azr999kjtoly53Acm3LqL8f98,9724
|
|
8
9
|
XMWAI/web_core.py,sha256=7awPg1kYW3lYrbgylqJvUF3g050bn6H21PgmQ7Kv1wA,10927
|
|
9
|
-
XMWAI/assets/
|
|
10
|
-
XMWAI/assets/
|
|
11
|
-
XMWAI/assets/h.png,sha256=qO-kJJOPA8qUth5rqLeOVa_6_n7tU-ABQ14O0EW_YCE,14929
|
|
12
|
-
XMWAI/assets/l.png,sha256=Urm6LxH33HID6ZZbs2oMViUk4GiZ3upLPdsrNU8FlP0,9921
|
|
13
|
-
XMWAI/assets/m.png,sha256=4tl9Rb2JoMD7XLMj3w8jg-92y6D7O-1u0sZCYEoeUtk,10303
|
|
14
|
-
XMWAI/assets/s.png,sha256=v_qmHGmSPhG838vXQdUR2ZX_Z5KLI8T46kaR4P_ktUg,15120
|
|
15
|
-
XMWAI/assets/t.png,sha256=GebzA2UWhXn4u62UeuUjitdpwnJvnxfZ2z_4MFlxvm8,12838
|
|
16
|
-
XMWAI/assets/微软雅黑.ttf,sha256=dpc4EmGE1ojdwHjfIwTdr3olyEDAk3FwyreQSC9AdQ8,15043584
|
|
10
|
+
XMWAI/assets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
XMWAI/assets/like.png,sha256=KOdVR3AXLSHTD-fZ0Efspr52qUpN3QrVjoTmww9AyRw,41801
|
|
17
12
|
XMWAI/file/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
13
|
XMWAI/file/idiom.json,sha256=HUtPRUzhxBbWoasjadbmbA_5ngQ5AXLu9weQSZ4hzhk,10319857
|
|
19
14
|
XMWAI/gif/0.gif,sha256=LGpAReVTyZEb1J-bWYTpxxHbIxmLJ-3wA0lw4cBqdsY,303
|
|
@@ -116,8 +111,8 @@ XMWAI/static/images/tomato.png,sha256=FEOEAOdUhW_BDFgTpxOkYc0I5Iu29_gtHb3RIPEej0
|
|
|
116
111
|
XMWAI/templates/burger.html,sha256=vDnxpSW8phetyScySsalScZnFKl3LNpy5lJjKxGXgbI,3320
|
|
117
112
|
XMWAI/templates/nutrition_pie.html,sha256=yJVXI28i-UfvF0xOXGSNLMb8oCJNhh2J3zoRDr5_7DM,5567
|
|
118
113
|
XMWAI/templates/创意菜谱.html,sha256=RcDgH58QLyUJ9A59wobu3wvchGBY1snVsXcZQZam5M0,4805
|
|
119
|
-
xmwai-0.4.
|
|
120
|
-
xmwai-0.4.
|
|
121
|
-
xmwai-0.4.
|
|
122
|
-
xmwai-0.4.
|
|
123
|
-
xmwai-0.4.
|
|
114
|
+
xmwai-0.4.8.dist-info/licenses/LICENSE.txt,sha256=bcaIQMrIhdQ3O-PoZlexjmW6h-wLGvHxh5Oksl4ohtc,1066
|
|
115
|
+
xmwai-0.4.8.dist-info/METADATA,sha256=se0Ev1GtEJFnxZTMzI6xtmKmsVRJCzSD2Y8wiEJJ47s,1266
|
|
116
|
+
xmwai-0.4.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
117
|
+
xmwai-0.4.8.dist-info/top_level.txt,sha256=yvGcDI-sggK5jqd9wz0saipZvk3oIE3hNGHlqUjxf0c,6
|
|
118
|
+
xmwai-0.4.8.dist-info/RECORD,,
|
XMWAI/assets/1.png
DELETED
|
Binary file
|
XMWAI/assets/g.png
DELETED
|
Binary file
|
XMWAI/assets/h.png
DELETED
|
Binary file
|
XMWAI/assets/l.png
DELETED
|
Binary file
|
XMWAI/assets/m.png
DELETED
|
Binary file
|
XMWAI/assets/s.png
DELETED
|
Binary file
|
XMWAI/assets/t.png
DELETED
|
Binary file
|