chatgpt-mirai-qq-bot-web-search 0.2.6__py3-none-any.whl → 0.2.7__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.6.dist-info → chatgpt_mirai_qq_bot_web_search-0.2.7.dist-info}/METADATA +1 -1
- {chatgpt_mirai_qq_bot_web_search-0.2.6.dist-info → chatgpt_mirai_qq_bot_web_search-0.2.7.dist-info}/RECORD +7 -7
- web_search/web_searcher.py +33 -23
- {chatgpt_mirai_qq_bot_web_search-0.2.6.dist-info → chatgpt_mirai_qq_bot_web_search-0.2.7.dist-info}/LICENSE +0 -0
- {chatgpt_mirai_qq_bot_web_search-0.2.6.dist-info → chatgpt_mirai_qq_bot_web_search-0.2.7.dist-info}/WHEEL +0 -0
- {chatgpt_mirai_qq_bot_web_search-0.2.6.dist-info → chatgpt_mirai_qq_bot_web_search-0.2.7.dist-info}/entry_points.txt +0 -0
- {chatgpt_mirai_qq_bot_web_search-0.2.6.dist-info → chatgpt_mirai_qq_bot_web_search-0.2.7.dist-info}/top_level.txt +0 -0
@@ -1,11 +1,11 @@
|
|
1
1
|
web_search/__init__.py,sha256=bpu1gpf9tq3mOAoaGMM-8S6GBw2GzRAG6ClHGlp-CVw,4607
|
2
2
|
web_search/blocks.py,sha256=QuXt3KMuY4hUW-ucleNYXFvW6YbUAB4Xu4m_SxdCd-U,9152
|
3
3
|
web_search/config.py,sha256=DhLiERBJR2V5Boglf7Aq9Rbc4vsvLIh67CrLDIPeqA0,398
|
4
|
-
web_search/web_searcher.py,sha256=
|
4
|
+
web_search/web_searcher.py,sha256=Bgnc0HGXZkMULZ5BWCJxBUzLFew19LuTL7lmdeqmfWs,21384
|
5
5
|
web_search/example/roleplayWithWebSearch.yaml,sha256=C-dGy3z8gcRcmxzurssP-kPRLqMf1TYR-nnNUaJjISE,7468
|
6
|
-
chatgpt_mirai_qq_bot_web_search-0.2.
|
7
|
-
chatgpt_mirai_qq_bot_web_search-0.2.
|
8
|
-
chatgpt_mirai_qq_bot_web_search-0.2.
|
9
|
-
chatgpt_mirai_qq_bot_web_search-0.2.
|
10
|
-
chatgpt_mirai_qq_bot_web_search-0.2.
|
11
|
-
chatgpt_mirai_qq_bot_web_search-0.2.
|
6
|
+
chatgpt_mirai_qq_bot_web_search-0.2.7.dist-info/LICENSE,sha256=ILBn-G3jdarm2w8oOrLmXeJNU3czuJvVhDLBASWdhM8,34522
|
7
|
+
chatgpt_mirai_qq_bot_web_search-0.2.7.dist-info/METADATA,sha256=88N33AlLdzPyW0GtLU8eDH0qGEKbqmHpl0UYooIU2-E,1734
|
8
|
+
chatgpt_mirai_qq_bot_web_search-0.2.7.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
9
|
+
chatgpt_mirai_qq_bot_web_search-0.2.7.dist-info/entry_points.txt,sha256=o3kRDSdSmSdnCKlK6qS57aN0WpI4ab-Nxub2NwUrjf0,64
|
10
|
+
chatgpt_mirai_qq_bot_web_search-0.2.7.dist-info/top_level.txt,sha256=PoNm8MJYw_y8RTMaNlY0ePLoNHxVUAE2IHDuL5fFubI,11
|
11
|
+
chatgpt_mirai_qq_bot_web_search-0.2.7.dist-info/RECORD,,
|
web_search/web_searcher.py
CHANGED
@@ -268,10 +268,12 @@ class WebSearcher:
|
|
268
268
|
if engine == 'google':
|
269
269
|
await self.simulate_human_scroll(page)
|
270
270
|
|
271
|
+
timeout = 5000
|
271
272
|
for selector in engine_config['selectors']:
|
272
273
|
try:
|
273
274
|
logger.info(f"Trying selector: {selector}")
|
274
|
-
await page.wait_for_selector(selector, timeout=
|
275
|
+
await page.wait_for_selector(selector, timeout=timeout) # 增加等待时间
|
276
|
+
timeout = 500
|
275
277
|
results = await page.query_selector_all(selector)
|
276
278
|
if results and len(results) > 0:
|
277
279
|
logger.info(f"Found {len(results)} results with selector {selector}")
|
@@ -281,28 +283,36 @@ class WebSearcher:
|
|
281
283
|
continue
|
282
284
|
|
283
285
|
if not results:
|
284
|
-
#
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
286
|
+
# 添加重试机制
|
287
|
+
retry_count = 0
|
288
|
+
while not results and retry_count < max_results:
|
289
|
+
logger.info(f"Retrying search, attempt {retry_count + 1}/{max_results}")
|
290
|
+
# 刷新页面重试
|
291
|
+
await page.reload(wait_until='load', timeout=timeout * 1000)
|
292
|
+
await self.simulate_human_scroll(page)
|
293
|
+
|
294
|
+
# 重新尝试所有选择器
|
295
|
+
timeout = 5000
|
296
|
+
for selector in engine_config['selectors']:
|
297
|
+
try:
|
298
|
+
logger.info(f"Retrying selector: {selector}")
|
299
|
+
await page.wait_for_selector(selector, timeout=timeout)
|
300
|
+
timeout = 500
|
301
|
+
results = await page.query_selector_all(selector)
|
302
|
+
if results and len(results) > 0:
|
303
|
+
logger.info(f"Found {len(results)} results with selector {selector} on retry {retry_count + 1}")
|
304
|
+
break
|
305
|
+
except Exception as e:
|
306
|
+
logger.warning(f"Selector {selector} failed on retry {retry_count + 1}: {e}")
|
307
|
+
continue
|
308
|
+
|
309
|
+
retry_count += 1
|
310
|
+
|
311
|
+
|
312
|
+
# 如果所有重试都失败了,才返回错误
|
313
|
+
if not results:
|
314
|
+
logger.error("No search results found after all retries")
|
315
|
+
return "搜索结果加载失败"
|
306
316
|
|
307
317
|
logger.info(f"Found {len(results)} search results")
|
308
318
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|