chatgpt-mirai-qq-bot-web-search 0.2.10__py3-none-any.whl → 0.2.12__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.
- {chatgpt_mirai_qq_bot_web_search-0.2.10.dist-info → chatgpt_mirai_qq_bot_web_search-0.2.12.dist-info}/METADATA +1 -1
- chatgpt_mirai_qq_bot_web_search-0.2.12.dist-info/RECORD +11 -0
- web_search/__init__.py +4 -2
- web_search/web_searcher.py +7 -8
- chatgpt_mirai_qq_bot_web_search-0.2.10.dist-info/RECORD +0 -11
- {chatgpt_mirai_qq_bot_web_search-0.2.10.dist-info → chatgpt_mirai_qq_bot_web_search-0.2.12.dist-info}/LICENSE +0 -0
- {chatgpt_mirai_qq_bot_web_search-0.2.10.dist-info → chatgpt_mirai_qq_bot_web_search-0.2.12.dist-info}/WHEEL +0 -0
- {chatgpt_mirai_qq_bot_web_search-0.2.10.dist-info → chatgpt_mirai_qq_bot_web_search-0.2.12.dist-info}/entry_points.txt +0 -0
- {chatgpt_mirai_qq_bot_web_search-0.2.10.dist-info → chatgpt_mirai_qq_bot_web_search-0.2.12.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
web_search/__init__.py,sha256=_vfIxeLqXc53QoZ8sHzw_SbGkxb2CTRQdd1phQmC8GM,6147
|
2
|
+
web_search/blocks.py,sha256=QuXt3KMuY4hUW-ucleNYXFvW6YbUAB4Xu4m_SxdCd-U,9152
|
3
|
+
web_search/config.py,sha256=DhLiERBJR2V5Boglf7Aq9Rbc4vsvLIh67CrLDIPeqA0,398
|
4
|
+
web_search/web_searcher.py,sha256=W0qOJv9cwzoxq-GKWbWiPZMshS6g0G5OB8_SS75B5f4,21761
|
5
|
+
web_search/example/roleplayWithWebSearch.yaml,sha256=C-dGy3z8gcRcmxzurssP-kPRLqMf1TYR-nnNUaJjISE,7468
|
6
|
+
chatgpt_mirai_qq_bot_web_search-0.2.12.dist-info/LICENSE,sha256=ILBn-G3jdarm2w8oOrLmXeJNU3czuJvVhDLBASWdhM8,34522
|
7
|
+
chatgpt_mirai_qq_bot_web_search-0.2.12.dist-info/METADATA,sha256=n6jsXNDBGTDMwrR6-dcz6FquMFufee9gApqA-NRXa0A,1735
|
8
|
+
chatgpt_mirai_qq_bot_web_search-0.2.12.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
9
|
+
chatgpt_mirai_qq_bot_web_search-0.2.12.dist-info/entry_points.txt,sha256=o3kRDSdSmSdnCKlK6qS57aN0WpI4ab-Nxub2NwUrjf0,64
|
10
|
+
chatgpt_mirai_qq_bot_web_search-0.2.12.dist-info/top_level.txt,sha256=PoNm8MJYw_y8RTMaNlY0ePLoNHxVUAE2IHDuL5fFubI,11
|
11
|
+
chatgpt_mirai_qq_bot_web_search-0.2.12.dist-info/RECORD,,
|
web_search/__init__.py
CHANGED
@@ -45,7 +45,8 @@ class WebSearchPlugin(Plugin):
|
|
45
45
|
)
|
46
46
|
stdout, stderr = process.communicate()
|
47
47
|
if process.returncode != 0:
|
48
|
-
|
48
|
+
logger.error(f"Failed to install playwright browsers: {stderr}")
|
49
|
+
raise RuntimeError(f"Failed to install playwright browsers: {stderr}")
|
49
50
|
except Exception as e:
|
50
51
|
logger.info("Installing playwright browsers...")
|
51
52
|
process = subprocess.Popen(
|
@@ -55,7 +56,8 @@ class WebSearchPlugin(Plugin):
|
|
55
56
|
)
|
56
57
|
stdout, stderr = process.communicate()
|
57
58
|
if process.returncode != 0:
|
58
|
-
|
59
|
+
logger.error(f"Failed to install playwright browsers: {stderr}")
|
60
|
+
raise RuntimeError(f"Failed to install playwright browsers: {stderr}")
|
59
61
|
# 注册Block
|
60
62
|
try:
|
61
63
|
self.block_registry.register("web_search", "search", WebSearchBlock)
|
web_search/web_searcher.py
CHANGED
@@ -163,9 +163,9 @@ class WebSearcher:
|
|
163
163
|
# 创建新标签页获取内容
|
164
164
|
page = await context.new_page()
|
165
165
|
try:
|
166
|
-
#
|
166
|
+
# 设置更严格的资源加载策略
|
167
167
|
await page.route("**/*", lambda route: route.abort()
|
168
|
-
if route.request.resource_type in ['image', 'font', 'media']
|
168
|
+
if route.request.resource_type in ['image', 'stylesheet', 'font', 'media']
|
169
169
|
else route.continue_())
|
170
170
|
|
171
171
|
# 使用 domcontentloaded 而不是 networkidle
|
@@ -263,8 +263,6 @@ class WebSearcher:
|
|
263
263
|
|
264
264
|
# 使用搜索引擎特定的选择器
|
265
265
|
results = None
|
266
|
-
# 等待页面稳定
|
267
|
-
await asyncio.sleep(2) # 添加短暂延迟
|
268
266
|
|
269
267
|
# 对于Google,让页面有更多时间加载
|
270
268
|
if engine == 'google':
|
@@ -344,9 +342,10 @@ class WebSearcher:
|
|
344
342
|
logger.error(f"Search failed - Query: {query} - Error: {e}", exc_info=True)
|
345
343
|
return f"搜索失败: {str(e)}"
|
346
344
|
finally:
|
347
|
-
if
|
345
|
+
if context:
|
348
346
|
try:
|
349
|
-
|
347
|
+
logger.debug("context.close")
|
348
|
+
await context.close()
|
350
349
|
except Exception as e:
|
351
350
|
logger.error(f"Error closing page: {e}")
|
352
351
|
|
@@ -491,8 +490,8 @@ class WebSearcher:
|
|
491
490
|
logger.error(f"抖音视频搜索失败 - 关键词: {keyword} - 错误: {e}", exc_info=True)
|
492
491
|
return f"搜索失败: {str(e)}"
|
493
492
|
finally:
|
494
|
-
if
|
493
|
+
if context:
|
495
494
|
try:
|
496
|
-
await
|
495
|
+
await context.close()
|
497
496
|
except Exception as e:
|
498
497
|
logger.error(f"关闭页面错误: {e}")
|
@@ -1,11 +0,0 @@
|
|
1
|
-
web_search/__init__.py,sha256=yhYI7F6dFaFSz4rKdE3BCMJ2X0x4tgp4yEVtKaLVG8Q,5995
|
2
|
-
web_search/blocks.py,sha256=QuXt3KMuY4hUW-ucleNYXFvW6YbUAB4Xu4m_SxdCd-U,9152
|
3
|
-
web_search/config.py,sha256=DhLiERBJR2V5Boglf7Aq9Rbc4vsvLIh67CrLDIPeqA0,398
|
4
|
-
web_search/web_searcher.py,sha256=wjhe6vqhnPvxhK4ssvmCAjvefQP6iE_7CpyhhHdY4a8,21813
|
5
|
-
web_search/example/roleplayWithWebSearch.yaml,sha256=C-dGy3z8gcRcmxzurssP-kPRLqMf1TYR-nnNUaJjISE,7468
|
6
|
-
chatgpt_mirai_qq_bot_web_search-0.2.10.dist-info/LICENSE,sha256=ILBn-G3jdarm2w8oOrLmXeJNU3czuJvVhDLBASWdhM8,34522
|
7
|
-
chatgpt_mirai_qq_bot_web_search-0.2.10.dist-info/METADATA,sha256=ahbVLiN43oJbQ6snNcHfgLassbQ5WLlA-B2F2Dr8ZtI,1735
|
8
|
-
chatgpt_mirai_qq_bot_web_search-0.2.10.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
9
|
-
chatgpt_mirai_qq_bot_web_search-0.2.10.dist-info/entry_points.txt,sha256=o3kRDSdSmSdnCKlK6qS57aN0WpI4ab-Nxub2NwUrjf0,64
|
10
|
-
chatgpt_mirai_qq_bot_web_search-0.2.10.dist-info/top_level.txt,sha256=PoNm8MJYw_y8RTMaNlY0ePLoNHxVUAE2IHDuL5fFubI,11
|
11
|
-
chatgpt_mirai_qq_bot_web_search-0.2.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|