大模型网页版内容聚合工具:一键获取多个AI助手的回答

张开发
2026/5/17 14:27:52 15 分钟阅读
大模型网页版内容聚合工具:一键获取多个AI助手的回答
大模型网页版内容聚合工具一键获取多个AI助手的回答背景为什么需要聚合AI平台的搜索结果操作步骤第一步下载并配置Chrome浏览器专用驱动第二步以调试模式启动Chrome第三步依次打开AI平台链接并手动登录第四步运行聚合脚本Python第五步用Claude汇总所有回答常见问题与注意事项总结你是否曾经为了同一个问题要分别打开Kimi、DeepSeek、通义千问等好几个AI助手复制粘贴它们的回答本教程将教你如何用Python脚本自动打开这些AI平台输入你的问题等待它们生成回答最后把所有回答保存成Markdown文件。整个过程只需要运行一次脚本就能拿到所有结果。背景为什么需要聚合AI平台的搜索结果目前市面上的大模型AI助手各有千秋有的擅长逻辑推理有的创意丰富有的回答更贴近中文习惯。如果你想全面了解某个问题的答案往往需要分别询问多个AI。手动操作不仅费时还容易漏掉重要信息。因此我们开发了一个自动化工具能够同时向多个AI平台提问自动等待每个平台生成完整回答提取回答内容并保存为Markdown文件最后用Claude另一个AI将这些回答整合成一份总结报告这样你就能高效地获得多方观点节省大量时间。操作步骤第一步下载并配置Chrome浏览器专用驱动我们的脚本需要模拟真实用户操作浏览器。Selenium是一个自动化测试工具可以控制Chrome完成点击、输入等动作。要让Selenium控制Chrome需要两个组件Chrome浏览器本身用于显示页面ChromeDriver相当于“遥控器”通过它向Chrome发送指令请下载以下两个压缩包版本号可能更新但这里使用的是Chrome 147.0.7727.50# ChromeDriver遥控器https://storage.googleapis.com/chrome-for-testing-public/147.0.7727.50/win64/chromedriver-win64.zip# Chrome浏览器无界面也可但这里我们使用完整版https://storage.googleapis.com/chrome-for-testing-public/147.0.7727.50/win64/chrome-win64.zip下载后解压到本地文件夹。关键操作将chromedriver.exe所在的目录添加到系统的PATH环境变量中。这样任何命令行窗口都能直接调用chromedriver。如果你不熟悉环境变量配置可以搜索“如何添加PATH环境变量”。第二步以调试模式启动Chrome为了让Python脚本连接到一个已经打开的Chrome窗口而不是每次新开一个我们需要用“远程调试”模式启动Chrome。这样脚本就可以通过9222端口与浏览器对话保持你已登录的会话状态避免重复登录。打开命令行CMD或PowerShell进入你解压后的chrome-win64文件夹运行chrome.exe --remote-debugging-port9222执行后会弹出一个新的Chrome窗口。请保持这个窗口一直开着不要关闭。第三步依次打开AI平台链接并手动登录由于各大AI平台都需要登录账号而自动登录涉及验证码等复杂问题我们采用半自动方式你用浏览器手动登录一次后续脚本就能复用这个已登录状态。在刚才启动的Chrome窗口中依次打开下面每个链接用手机号或邮箱登录供应商链接Kimi (月之暗面)https://www.kimi.com/deepseekhttps://chat.deepseek.com/a/chat通义千问 (阿里)https://www.qianwen.com/豆包 (字节跳动)https://www.doubao.com/chat腾讯元宝https://yuanbao.tencent.com/chat/naQivTmsDa小贴士登录后最好保持每个页面都处于空白聊天状态没有历史消息干扰。登录一次就够了以后只要不关闭这个调试模式的Chrome窗口下次运行脚本时无需再登录。第四步运行聚合脚本Python这是整个工具的核心。你需要安装Python环境建议3.8以上然后安装依赖库pipinstallselenium html2textselenium负责控制浏览器html2text把网页中的HTML内容转换成Markdown格式将下面的完整脚本保存为一个文件比如ai_aggregator.py。脚本中已经配置好了每个平台的输入框、发送按钮、等待回答完成的方式等。 多平台AI热点搜索工具 聚合多个AI平台的搜索结果生成markdown文件 importtimeimportosfromseleniumimportwebdriverfromselenium.webdriver.chrome.optionsimportOptionsfromselenium.webdriver.common.byimportByfromselenium.webdriver.support.uiimportWebDriverWaitfromselenium.webdriver.supportimportexpected_conditionsasECfromselenium.webdriver.common.action_chainsimportActionChainsfromselenium.common.exceptionsimportTimeoutExceptionimporthtml2text# 公共工具函数 defget_driver():创建Chrome驱动连接到已打开的浏览器optionsOptions()options.add_experimental_option(debuggerAddress,127.0.0.1:9222)returnwebdriver.Chrome(optionsoptions)defhtml_to_markdown(inner_html):将HTML转换为markdown格式converterhtml2text.HTML2Text()converter.ignore_linksFalseconverter.ignore_imagesFalseconverter.body_width0returnconverter.handle(inner_html)defextract_content(driver,content_xpath):提取页面中的内容并转换为markdowncontentsdriver.find_elements(By.XPATH,content_xpath)final_contentforcontentincontents:inner_htmlcontent.get_attribute(outerHTML)markdown_texthtml_to_markdown(inner_html)iflen(markdown_text)len(final_content):final_contentmarkdown_textreturnfinal_contentdefwait_for_response(driver,wait_selector,wait_xpathNone):等待响应完成time.sleep(2)wait_longWebDriverWait(driver,60*10)ifwait_selectorclass:wait_long.until(lambdad:stopnotind.find_element(By.CSS_SELECTOR,wait_xpath).get_attribute(class))elifwait_selectorxpath:wait_long.until(EC.presence_of_element_located((By.XPATH,wait_xpath)))elifwait_selectorinvisible:wait_long.until(EC.invisibility_of_element_located((By.XPATH,wait_xpath)))elifwait_selectordisabled:wait_long.until(EC.presence_of_element_located((By.XPATH,wait_xpath)))defclick_send_button(driver,send_selector,send_value):点击发送按钮ifsend_selectorxpath:snd_elementdriver.find_element(By.XPATH,send_value)else:snd_elementdriver.find_element(By.CSS_SELECTOR,send_value)ActionChains(driver).move_to_element(snd_element).click().perform()# 平台配置 PLATFORMS{deepseek:{url:https://chat.deepseek.com/a/chat,input_xpath://textarea[placeholder给 DeepSeek 发送消息 ],send_method:enter,# 使用回车发送wait_selector:disabled,wait_xpath://div[contains(class, ds-icon-button--disabled)],content_xpath://div[classds-markdown],output_file:deepseek.md},doubao:{url:https://www.doubao.com/chat,input_xpath://textarea[placeholder发消息...],send_selector:xpath,send_value://button[data-testidchat_input_send_button],wait_selector:xpath,wait_xpath://div[data-stateinactive],content_xpath://div[data-testidmessage_text_content],output_file:doubao.md},kimi:{url:https://www.kimi.com/,input_xpath://div[classchat-input-editor],input_click_xpath://div[classchat-input-placeholder],send_selector:css,send_value:div.send-button-container,wait_selector:class,wait_xpath:.send-button-container,content_xpath://div[classsegment-content],output_file:kimi.md},qianwen:{url:https://www.qianwen.com/,input_xpath://div[data-placeholder向千问提问],send_selector:xpath,send_value://button[aria-label发送消息],wait_selector:invisible,wait_xpath://button[aria-label停止回答],content_xpath://div[classmarkdown-pc-special-class],output_file:qianwen.md},yuanbao:{url:https://yuanbao.tencent.com/chat/naQivTmsDa,input_xpath://div[data-placeholder有问题尽管问shiftenter换行],send_selector:xpath,send_value://a[idyuanbao-send-btn],wait_selector:xpath,wait_xpath://a[idyuanbao-send-btn],content_xpath://div[classhyc-content-md hyc-content-md-done],output_file:yuanbao.md}}# 核心实现 defsearch_platform(platform_name,query,max_retries3):搜索单个平台支持重试机制configPLATFORMS.get(platform_name)ifnotconfig:print(f未知平台:{platform_name})returnFalseoutput_fileconfig[output_file]forattemptinrange(1,max_retries1):print(f[{platform_name}] 第{attempt}次尝试...)try:driverget_driver()waitWebDriverWait(driver,10)driver.get(config[url])# 点击输入框部分平台需要ifinput_click_xpathinconfig:placeholderwait.until(EC.element_to_be_clickable((By.XPATH,config[input_click_xpath])))ActionChains(driver).move_to_element(placeholder).click().perform()# 输入查询内容input_boxwait.until(EC.presence_of_element_located((By.XPATH,config[input_xpath])))input_box.send_keys(query)# 发送内容send_methodconfig.get(send_method,click)ifsend_methodenter:fromselenium.webdriver.common.keysimportKeys ActionChains(driver).send_keys(Keys.ENTER).perform()else:click_send_button(driver,config[send_selector],config[send_value])# 等待响应wait_for_response(driver,config[wait_selector],config.get(wait_xpath))# 提取内容final_contentextract_content(driver,config[content_xpath])# 保存文件iffinal_content:withopen(output_file,w,encodingutf-8)asf:f.write(final_content)print(f[{platform_name}] 成功保存到{output_file})driver.quit()returnTrueelse:print(f[{platform_name}] 未获取到内容)exceptTimeoutException:print(f[{platform_name}] 超时)exceptExceptionase:print(f[{platform_name}] 错误:{e})finally:try:driver.quit()except:pass# 检查文件是否生成ifos.path.exists(output_file)andos.path.getsize(output_file)0:print(f[{platform_name}] 文件已生成)returnTrue# 重试前等待ifattemptmax_retries:print(f[{platform_name}] 等待2秒后重试...)time.sleep(2)print(f[{platform_name}] 达到最大重试次数({max_retries})仍未成功)returnFalsedefmain(query获取近一周AI咨询,platformsNone):主函数ifplatformsisNone:platforms[deepseek,doubao,kimi,qianwen,yuanbao]results{}forplatforminplatforms:print(f\n{*20}正在搜索{platform}{*20})results[platform]search_platform(platform,query)time.sleep(1)# 平台间间隔# 打印结果汇总print(f\n{*20}搜索结果汇总{*20})forplatform,successinresults.items():status成功ifsuccesselse失败print(f{platform}:{status})returnresultsif__name____main__:# 你可以修改这里的query为你感兴趣的问题query获取近一周AI咨询main(query)如何运行确保之前的调试Chrome窗口仍然打开然后在命令行执行python ai_aggregator.py脚本会自动依次访问每个平台输入你预设的问题示例中是“获取近一周AI咨询”等待回答然后保存为单独的Markdown文件如deepseek.md、doubao.md等。第五步用Claude汇总所有回答现在你有了多个Markdown文件每个文件是一个AI的回答。如果你想得到一份综合报告可以使用Claude另一个大模型来整合它们。假设你已经安装了claude命令行工具或者你可以直接复制粘贴内容到Claude网页版运行claude --dangerously-skip-permissions --output-format json-p整合当前目录下的markdown文件,输出summary.md这条命令的意思是让Claude读取当前文件夹下所有.md文件分析它们的内容然后生成一份总结报告summary.md。--dangerously-skip-permissions是跳过权限确认仅在可信环境使用-p后面是提示词。如果你没有claude命令行工具也可以手动将所有.md文件的内容复制到Claude网页版并说“请帮我总结这些AI回答输出一个综合报告”。常见问题与注意事项为什么脚本会报错“找不到Chrome”请检查你是否以调试模式启动了Chrome并且端口是9222。也可以尝试在脚本中指定Chrome路径。为什么某个平台总是超时可能是网页结构发生了变化AI平台经常更新界面。你需要打开浏览器的开发者工具F12重新查找输入框、发送按钮、回答内容的XPath并更新脚本中的配置。可以不手动登录吗理论上可以但需要处理验证码、短信等复杂问题。本教程采用半自动方式更稳定可靠。脚本能同时运行多个平台吗不能因为需要共用一个Chrome窗口。脚本是顺序执行的一个完成后再处理下一个。如果我想问不同的问题怎么办修改脚本最后一行query变量的值或者通过命令行参数传递需要稍微修改脚本。总结通过这个工具你可以自动化收集多个AI助手的回答标准化输出为Markdown格式方便阅读和存档集成最终用Claude生成综合报告整个过程只需要你手动登录一次之后就可以反复运行脚本快速获取多方观点。希望这个教程对你有所帮助你也可以根据自己的需求修改脚本适配更多AI平台。

更多文章