chatgpt-mirai-qq-bot-web-search 0.2.11__tar.gz → 0.2.13__tar.gz
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.11 → chatgpt-mirai-qq-bot-web-search-0.2.13}/PKG-INFO +1 -1
- {chatgpt-mirai-qq-bot-web-search-0.2.11 → chatgpt-mirai-qq-bot-web-search-0.2.13}/chatgpt_mirai_qq_bot_web_search.egg-info/PKG-INFO +1 -1
- {chatgpt-mirai-qq-bot-web-search-0.2.11 → chatgpt-mirai-qq-bot-web-search-0.2.13}/setup.py +1 -1
- {chatgpt-mirai-qq-bot-web-search-0.2.11 → chatgpt-mirai-qq-bot-web-search-0.2.13}/web_search/__init__.py +4 -2
- {chatgpt-mirai-qq-bot-web-search-0.2.11 → chatgpt-mirai-qq-bot-web-search-0.2.13}/web_search/web_searcher.py +7 -16
- {chatgpt-mirai-qq-bot-web-search-0.2.11 → chatgpt-mirai-qq-bot-web-search-0.2.13}/LICENSE +0 -0
- {chatgpt-mirai-qq-bot-web-search-0.2.11 → chatgpt-mirai-qq-bot-web-search-0.2.13}/README.md +0 -0
- {chatgpt-mirai-qq-bot-web-search-0.2.11 → chatgpt-mirai-qq-bot-web-search-0.2.13}/chatgpt_mirai_qq_bot_web_search.egg-info/SOURCES.txt +0 -0
- {chatgpt-mirai-qq-bot-web-search-0.2.11 → chatgpt-mirai-qq-bot-web-search-0.2.13}/chatgpt_mirai_qq_bot_web_search.egg-info/dependency_links.txt +0 -0
- {chatgpt-mirai-qq-bot-web-search-0.2.11 → chatgpt-mirai-qq-bot-web-search-0.2.13}/chatgpt_mirai_qq_bot_web_search.egg-info/entry_points.txt +0 -0
- {chatgpt-mirai-qq-bot-web-search-0.2.11 → chatgpt-mirai-qq-bot-web-search-0.2.13}/chatgpt_mirai_qq_bot_web_search.egg-info/requires.txt +0 -0
- {chatgpt-mirai-qq-bot-web-search-0.2.11 → chatgpt-mirai-qq-bot-web-search-0.2.13}/chatgpt_mirai_qq_bot_web_search.egg-info/top_level.txt +0 -0
- {chatgpt-mirai-qq-bot-web-search-0.2.11 → chatgpt-mirai-qq-bot-web-search-0.2.13}/setup.cfg +0 -0
- {chatgpt-mirai-qq-bot-web-search-0.2.11 → chatgpt-mirai-qq-bot-web-search-0.2.13}/web_search/blocks.py +0 -0
- {chatgpt-mirai-qq-bot-web-search-0.2.11 → chatgpt-mirai-qq-bot-web-search-0.2.13}/web_search/config.py +0 -0
- {chatgpt-mirai-qq-bot-web-search-0.2.11 → chatgpt-mirai-qq-bot-web-search-0.2.13}/web_search/example/roleplayWithWebSearch.yaml +0 -0
@@ -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)
|
@@ -31,8 +31,8 @@ class WebSearcher:
|
|
31
31
|
self.video_ids = self._load_video_ids()
|
32
32
|
self.search_engines = {
|
33
33
|
'bing': {
|
34
|
-
'url': 'https://
|
35
|
-
'selectors': ['.b_algo'
|
34
|
+
'url': 'https://www.bing.com/search?q={}',
|
35
|
+
'selectors': ['.b_algo'],
|
36
36
|
'title_selector': 'h2',
|
37
37
|
'link_selector': 'h2 a',
|
38
38
|
'snippet_selector': '.b_caption p'
|
@@ -260,7 +260,6 @@ class WebSearcher:
|
|
260
260
|
wait_until='load',
|
261
261
|
timeout=timeout * 1000
|
262
262
|
)
|
263
|
-
|
264
263
|
# 使用搜索引擎特定的选择器
|
265
264
|
results = None
|
266
265
|
|
@@ -268,7 +267,7 @@ class WebSearcher:
|
|
268
267
|
if engine == 'google':
|
269
268
|
await self.simulate_human_scroll(page)
|
270
269
|
|
271
|
-
selector_timeout =
|
270
|
+
selector_timeout = timeout * 1000
|
272
271
|
for selector in engine_config['selectors']:
|
273
272
|
try:
|
274
273
|
logger.info(f"Trying selector: {selector}")
|
@@ -297,7 +296,7 @@ class WebSearcher:
|
|
297
296
|
await self.simulate_human_scroll(page)
|
298
297
|
|
299
298
|
# 重新尝试所有选择器
|
300
|
-
selector_timeout =
|
299
|
+
selector_timeout = timeout * 1000
|
301
300
|
for selector in engine_config['selectors']:
|
302
301
|
try:
|
303
302
|
logger.info(f"Retrying selector: {selector}")
|
@@ -342,12 +341,8 @@ class WebSearcher:
|
|
342
341
|
logger.error(f"Search failed - Query: {query} - Error: {e}", exc_info=True)
|
343
342
|
return f"搜索失败: {str(e)}"
|
344
343
|
finally:
|
345
|
-
|
346
|
-
|
347
|
-
logger.debug("context.close")
|
348
|
-
await context.close()
|
349
|
-
except Exception as e:
|
350
|
-
logger.error(f"Error closing page: {e}")
|
344
|
+
await self.close()
|
345
|
+
|
351
346
|
|
352
347
|
async def close(self):
|
353
348
|
"""关闭浏览器"""
|
@@ -490,8 +485,4 @@ class WebSearcher:
|
|
490
485
|
logger.error(f"抖音视频搜索失败 - 关键词: {keyword} - 错误: {e}", exc_info=True)
|
491
486
|
return f"搜索失败: {str(e)}"
|
492
487
|
finally:
|
493
|
-
|
494
|
-
try:
|
495
|
-
await context.close()
|
496
|
-
except Exception as e:
|
497
|
-
logger.error(f"关闭页面错误: {e}")
|
488
|
+
await self.close()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|