lss233 / chatgpt-mirai-qq-bot

🚀 一键部署!真正的 AI 聊天机器人!支持ChatGPT、文心一言、讯飞星火、Bing、Bard、ChatGLM、POE,多账号,人设调教,虚拟女仆、图片渲染、语音发送 | 支持 QQ、Telegram、Discord、微信 等平台
GNU Affero General Public License v3.0
13.07k stars 1.56k forks source link

Expecting value: line 1 column 1 (char 0) #1268

Open zro227 opened 10 months ago

zro227 commented 10 months ago

提交 issue 前,请先确认:

表现
描述 BUG 的表现情况

运行环境:

复现步骤
描述你是如何触发这个 BUG 的 发消息无法回复

预期行为
如何设置才能正常回复我的话

截图
111

其他内容
此处填写其他内容,没有可跳过

Knday88 commented 9 months ago

我也是这样,你解决了吗

zro227 commented 9 months ago

并没有

Vsxbamboo commented 9 months ago

我使用的文心一言的接入方式,发现这个项目用来计算文心一言arc的网页服务https://chatgpt-proxy.lss233.com/yiyan-api/acs应该挂了。根据报错信息,在adapter/baidu/yiyan.py的192行返回处,req就变成了502.

Vsxbamboo commented 9 months ago

报错如下(有重复报错):

2023-12-14 00:34:41.665 | DEBUG    | platforms.onebot_bot:_:148 - 私聊消息:ask 你好
2023-12-14 00:34:42.276 | DEBUG    | middlewares.concurrentlock:handle_request:40 - [Concurrent] 排队中,前面还有 0 个人!
2023-12-14 00:34:42.361 | DEBUG    | middlewares.concurrentlock:handle_request:42 - [Concurrent] 排到了!
2023-12-14 00:34:42.395 | DEBUG    | platforms.onebot_bot:_:148 - 私聊消息:ask 你好
2023-12-14 00:34:42.482 | DEBUG    | middlewares.concurrentlock:handle_request:40 - [Concurrent] 排队中,前面还有 1 个人!
2023-12-14 00:34:42.573 | DEBUG    | platforms.onebot_bot:_:148 - 私聊消息:ask 你好
2023-12-14 00:34:42.603 | DEBUG    | middlewares.concurrentlock:handle_request:40 - [Concurrent] 排队中,前面还有 2 个人!
2023-12-14 00:34:42.693 | DEBUG    | middlewares.timeout:create_timeout_task:61 - [Timeout] 开始计时……
2023-12-14 00:34:43.665 | ERROR    | middlewares.timeout:handle_request:36 - 发生错误: Expecting value: line 1 column 1 (char 0)
2023-12-14 00:34:44.085 | ERROR    | universal:handle_message:297 - Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):

  File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\bot.py", line 58, in <module>
    loop.run_until_complete(asyncio.gather(*bots))
    │    │                  │       │       └ [<Task pending name='Task-2' coro=<start_task() running at C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.t...
    │    │                  │       └ <function gather at 0x000002791C830700>
    │    │                  └ <module 'asyncio' from 'C:\\Users\\Administrator\\Miniconda3\\envs\\chatgpt\\lib\\asyncio\\__init__.py'>
    │    └ <function BaseEventLoop.run_until_complete at 0x000002791C83D3F0>
    └ <ProactorEventLoop running=True closed=False debug=False>

  File "C:\Users\Administrator\Miniconda3\envs\chatgpt\lib\asyncio\base_events.py", line 636, in run_until_complete
    self.run_forever()
    │    └ <function ProactorEventLoop.run_forever at 0x000002791E4760E0>
    └ <ProactorEventLoop running=True closed=False debug=False>

  File "C:\Users\Administrator\Miniconda3\envs\chatgpt\lib\asyncio\windows_events.py", line 321, in run_forever
    super().run_forever()

  File "C:\Users\Administrator\Miniconda3\envs\chatgpt\lib\asyncio\base_events.py", line 603, in run_forever
    self._run_once()
    │    └ <function BaseEventLoop._run_once at 0x000002791C83EE60>
    └ <ProactorEventLoop running=True closed=False debug=False>

  File "C:\Users\Administrator\Miniconda3\envs\chatgpt\lib\asyncio\base_events.py", line 1909, in _run_once
    handle._run()
    │      └ <function Handle._run at 0x000002791C7DDFC0>
    └ <Handle Task.task_wakeup(<Future finished result=None>)>

  File "C:\Users\Administrator\Miniconda3\envs\chatgpt\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
    │    │            │    │           │    └ <member '_args' of 'Handle' objects>
    │    │            │    │           └ <Handle Task.task_wakeup(<Future finished result=None>)>
    │    │            │    └ <member '_callback' of 'Handle' objects>
    │    │            └ <Handle Task.task_wakeup(<Future finished result=None>)>
    │    └ <member '_context' of 'Handle' objects>
    └ <Handle Task.task_wakeup(<Future finished result=None>)>

  File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\platforms\onebot_bot.py", line 151, in _
    await handle_message(
          └ <function handle_message at 0x000002794803A8C0>

> File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\universal.py", line 271, in handle_message
    await action(session_id, message.strip(), conversation_context, respond)
          │      │           │       │        │                     └ <function handle_message.<locals>.respond at 0x0000027948259510>
          │      │           │       │        └ None
          │      │           │       └ <method 'strip' of 'str' objects>
          │      │           └ '你好'
          │      └ 'friend-1924868164'
          └ <function handle_message.<locals>.wrap_request.<locals>.call at 0x00000279482597E0>

  File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\universal.py", line 53, in call
    await m.handle_request(session_id, message, respond, conversation_context, n)
          │ │              │           │        │        │                     └ <function handle_message.<locals>.wrap_request.<locals>.call at 0x0000027948259750>
          │ │              │           │        │        └ None
          │ │              │           │        └ <function handle_message.<locals>.respond at 0x0000027948259510>
          │ │              │           └ '你好'
          │ │              └ 'friend-1924868164'
          │ └ <function MiddlewareConcurrentLock.handle_request at 0x000002794803AEF0>
          └ <middlewares.concurrentlock.MiddlewareConcurrentLock object at 0x000002794804C2B0>

  File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\middlewares\concurrentlock.py", line 43, in handle_request
    await action(session_id, prompt, conversation_context, respond)
          │      │           │       │                     └ <function handle_message.<locals>.respond at 0x0000027948259510>
          │      │           │       └ None
          │      │           └ '你好'
          │      └ 'friend-1924868164'
          └ <function handle_message.<locals>.wrap_request.<locals>.call at 0x0000027948259750>

  File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\universal.py", line 53, in call
    await m.handle_request(session_id, message, respond, conversation_context, n)
          │ │              │           │        │        │                     └ <function handle_message.<locals>.wrap_request.<locals>.call at 0x00000279482596C0>
          │ │              │           │        │        └ None
          │ │              │           │        └ <function handle_message.<locals>.respond at 0x0000027948259510>
          │ │              │           └ '你好'
          │ │              └ 'friend-1924868164'
          │ └ <function Middleware.handle_request at 0x000002794803A170>
          └ <middlewares.baiducloud.MiddlewareBaiduCloud object at 0x0000027947FFB3D0>

  File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\middlewares\middleware.py", line 9, in handle_request
    await action(session_id, prompt, conversation_context, respond)
          │      │           │       │                     └ <function handle_message.<locals>.respond at 0x0000027948259510>
          │      │           │       └ None
          │      │           └ '你好'
          │      └ 'friend-1924868164'
          └ <function handle_message.<locals>.wrap_request.<locals>.call at 0x00000279482596C0>

  File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\universal.py", line 53, in call
    await m.handle_request(session_id, message, respond, conversation_context, n)
          │ │              │           │        │        │                     └ <function handle_message.<locals>.wrap_request.<locals>.call at 0x0000027948259630>
          │ │              │           │        │        └ None
          │ │              │           │        └ <function handle_message.<locals>.respond at 0x0000027948259510>
          │ │              │           └ '你好'
          │ │              └ 'friend-1924868164'
          │ └ <function MiddlewareRatelimit.handle_request at 0x000002794803A3B0>
          └ <middlewares.ratelimit.MiddlewareRatelimit object at 0x0000027947FFB3A0>

  File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\middlewares\ratelimit.py", line 23, in handle_request
    await action(session_id, prompt, conversation_context, respond)
          │      │           │       │                     └ <function handle_message.<locals>.respond at 0x0000027948259510>
          │      │           │       └ None
          │      │           └ '你好'
          │      └ 'friend-1924868164'
          └ <function handle_message.<locals>.wrap_request.<locals>.call at 0x0000027948259630>

  File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\universal.py", line 53, in call
    await m.handle_request(session_id, message, respond, conversation_context, n)
          │ │              │           │        │        │                     └ <function handle_message.<locals>.request at 0x00000279482595A0>
          │ │              │           │        │        └ None
          │ │              │           │        └ <function handle_message.<locals>.respond at 0x0000027948259510>
          │ │              │           └ '你好'
          │ │              └ 'friend-1924868164'
          │ └ <function MiddlewareTimeout.handle_request at 0x000002794803B010>
          └ <middlewares.timeout.MiddlewareTimeout object at 0x0000027947FFB370>

  File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\middlewares\timeout.py", line 40, in handle_request
    raise e

  File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\middlewares\timeout.py", line 27, in handle_request
    await asyncio.wait_for(coro_task, config.response.max_timeout)
          │       │        │          │      │        └ 600.0
          │       │        │          │      └ Response(mode='mixed', buffer_delay=15, default_ai='yiyan', error_format='出现故障!如果这个问题持续出现,请和我说“重置会话” 来开启一段新的会话,或者发送 “回滚对话” 来回...
          │       │        │          └ Config(onebot=Onebot(manager_qq=1924868164, reverse_ws_host='0.0.0.0', reverse_ws_port=5900), mirai=None, telegram=None, disc...
          │       │        └ <Task finished name='Task-297' coro=<handle_message.<locals>.request() done, defined at C:\Users\Administrator\Desktop\Window...
          │       └ <function wait_for at 0x000002791C8301F0>
          └ <module 'asyncio' from 'C:\\Users\\Administrator\\Miniconda3\\envs\\chatgpt\\lib\\asyncio\\__init__.py'>

  File "C:\Users\Administrator\Miniconda3\envs\chatgpt\lib\asyncio\tasks.py", line 445, in wait_for
    return fut.result()
           │   └ <method 'result' of '_asyncio.Task' objects>
           └ <Task finished name='Task-297' coro=<handle_message.<locals>.request() done, defined at C:\Users\Administrator\Desktop\Window...

  File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\universal.py", line 224, in request
    async for rendered in task:
                          └ <async_generator object retry.<locals>.decorator.<locals>.wrapper at 0x0000027948223E40>

  File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\utils\retry.py", line 21, in wrapper
    async for result in func(*args, **kwargs):
                        │     │       └ {'prompt': '你好', 'chain': MessageChain([Plain(text='ask 你好')]), 'name': 'player_vsx'}
                        │     └ (<conversation.ConversationContext object at 0x00000279480DE290>,)
                        └ <function ConversationContext.ask at 0x0000027948039AB0>

  File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\conversation.py", line 195, in ask
    async for item in self.adapter.ask(prompt):
                      │    │       │   └ '你好'
                      │    │       └ <function YiyanAdapter.ask at 0x0000027946EE1000>
                      │    └ <adapter.baidu.yiyan.YiyanAdapter object at 0x00000279480DE2C0>
                      └ <conversation.ConversationContext object at 0x00000279480DE290>

  File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\adapter\baidu\yiyan.py", line 94, in ask
    self.client.headers['Acs-Token'] = await self.get_sign()
    │    │      │                            │    └ <function YiyanAdapter.get_sign at 0x0000027946EE11B0>
    │    │      │                            └ <adapter.baidu.yiyan.YiyanAdapter object at 0x00000279480DE2C0>
    │    │      └ <property object at 0x000002791FDE1350>
    │    └ <httpx.AsyncClient object at 0x00000279480DE590>
    └ <adapter.baidu.yiyan.YiyanAdapter object at 0x00000279480DE2C0>

  File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\adapter\baidu\yiyan.py", line 192, in get_sign
    return req.json()['acs']
           │   └ <function Response.json at 0x000002791FA0EB90>
           └ <Response [502 Bad Gateway]>

  File "C:\Users\Administrator\Miniconda3\envs\chatgpt\lib\site-packages\httpx\_models.py", line 756, in json
    return jsonlib.loads(self.text, **kwargs)
           │       │     │    │       └ {}
           │       │     │    └ <property object at 0x000002791FA10590>
           │       │     └ <Response [502 Bad Gateway]>
           │       └ <function loads at 0x000002791C197010>
           └ <module 'json' from 'C:\\Users\\Administrator\\Miniconda3\\envs\\chatgpt\\lib\\json\\__init__.py'>

  File "C:\Users\Administrator\Miniconda3\envs\chatgpt\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           │                │      └ '<!DOCTYPE html>\n<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->\n<!--[if IE 7]>    <html class="...
           │                └ <function JSONDecoder.decode at 0x000002791C1967A0>
           └ <json.decoder.JSONDecoder object at 0x000002791C18B970>

  File "C:\Users\Administrator\Miniconda3\envs\chatgpt\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               │    │          │      │  └ '<!DOCTYPE html>\n<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->\n<!--[if IE 7]>    <html class="...
               │    │          │      └ <built-in method match of re.Pattern object at 0x000002791BE03440>
               │    │          └ '<!DOCTYPE html>\n<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->\n<!--[if IE 7]>    <html class="...
               │    └ <function JSONDecoder.raw_decode at 0x000002791C196830>
               └ <json.decoder.JSONDecoder object at 0x000002791C18B970>

  File "C:\Users\Administrator\Miniconda3\envs\chatgpt\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
          │                                  └ '<!DOCTYPE html>\n<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->\n<!--[if IE 7]>    <html class="...
          └ <class 'json.decoder.JSONDecodeError'>

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Vsxbamboo commented 9 months ago

在github上找到了文心一言的网页版api封装,或可作为替代,但原作者的代码已经不能使用,我简单写了一个基于node.js的demo(有些杂乱,见谅,仅作为演示),现在是可以使用的,可以稍作修改。

import puppeteer, {KnownDevices} from 'puppeteer'
import sleep from 'then-sleep'

const cookie=''
const prompt='在所有对我的回答的末尾加上一个#,包括对这个问题的回答。'
const {texts}=await headless({
    cookie,
    prompt
})

console.log(texts)

async function headless({ cookie, timeout = 1000 * 60, headless = 'new', prompt = '' }) {
    let browser;
    cookie=''
    try {
        browser = await puppeteer.launch({
            headless,
            ignoreDefaultArgs: ['--enable-automation'],
            args: ['--disable-blink-features=AutomationControlled', '--no-sandbox', '--disable-setuid-sandbox'],
        });

        const page = await browser.newPage();
        await page.emulate(KnownDevices['iPhone SE']);

        // Check if 'cookie' is provided before using it
        if (cookie) {
            await page.setCookie(...parse_cookie(cookie));
        }

        await page.goto('https://yiyan.baidu.com', {waitUntil: 'networkidle0'})

        // 在 Node.js 环境中无法使用 document.body.innerText,使用 page.evaluate 来获取页面内容

        const message_input = await page.waitForSelector('#dialogue-input', {
            timeout,
        })

        await message_input.type(prompt)
        await sleep(1000)

        await page.evaluate(async () => {
            function get_parent_next_sibling(element) {
                const parent = element.parentNode
                let next_sibling = parent.nextSibling
                while (next_sibling && next_sibling.nodeType !== 1) {
                    next_sibling = next_sibling.nextSibling
                }
                return next_sibling
            }

            const message_input = document.querySelector('#dialogue-input')
            const send_button = get_parent_next_sibling(message_input)
            send_button.click()
        })

        // 使用 page.waitForFunction 等待条件成立
        await page.waitForFunction(
            () => {
                const elements = document.querySelectorAll('.custom-html');
                const lastElement = elements[elements.length - 1];
                return lastElement && lastElement.textContent.trim().endsWith('#');
            },
            { timeout: 6000 }  // 设置最大等待时间,例如 6000 毫秒(6 秒)
        );

        // 条件成立后的处理代码
        console.log('最后一个 .custom-html 元素的内容以 # 结尾');

        const texts = await page.evaluate(() => {
            // 获取包含文字的所有元素,通过类名查找
            const elements = document.querySelectorAll('.custom-html');

            // 遍历所有元素并提取文字内容
            let c=""
            for(let i=0;i<elements.length;i++){
                c=c+" "+elements[i].textContent
            }
            return c
        });

        return { texts }
    } finally {
        // 关闭浏览器
        await browser?.close();
    }
}

function parse_cookie(cookie) {
    return cookie
        .trim()
        .split('; ')
        .map(item => {
            const [name, ...value] = item.split('=');
            return {
                name: name?.trim(),
                value: value.join('='),
                domain: 'yiyan.baidu.com',
            };
        })
        .filter(item => item.name);
}
Vsxbamboo commented 9 months ago

~可以转而使用Python的pyppeter转写一下。~ 事实证明,如果pyppeteer没有绕过webDriver的检测的话,就不行。

Vsxbamboo commented 9 months ago

在github上找到了可能是本项目文心一言的参考项目https://github.com/XiaoXinYo/Easy-Ernie,因此,一种修改方法可能是借用那个项目的api。此时,那个项目的api仍然可用。据说说文心一言的acs-token计算参数经常改变。而且,根据项目用于提示更新api的issue猜测,此方法(指计算acs-token)访问次数多后会出现访问限制。

Vsxbamboo commented 9 months ago

尝试通过替换yiyan.py中的api后发现其中使用的请求方式应该已经过期,文心一言可能使用了新的/conversation/v2进行某种三合一的请求方式,即仅仅修改成前述库的api获取acs-token后也不能正常使用。

File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\adapter\baidu\yiyan.py", line 158, in ask
    self.__check_response(req.json())
    │                     │   └ <function Response.json at 0x00000219C9A5EB90>
    │                     └ <Response [200 OK]>
    └ <adapter.baidu.yiyan.YiyanAdapter object at 0x00000219F21A6320>
File "C:\Users\Administrator\Desktop\Windows-quickstart-go-cqhttp-refs.tags.v2.5.3\chatgpt-mirai-qq-bot\adapter\baidu\yiyan.py", line 190, in __check_response
    raise Exception(resp['msg'])
                    └ {'code': 9000002, 'msg': '三合一接口异常', 'data': {'createChatResponseVoCommonResult': {'code': 4001, 'msg': 'text is blank', 'data...

使用了python-playwright重写了一下前面借助puppeteer用nodejs实现的功能。好处是不用考虑acs-token的逆向破解了。坏处是程序变大,响应慢一点。然后需要绕过对这种模拟浏览器的自动测试程序的检测,目前已经绕过,担心后面。不过,据说acs-token也总是在改,绕过不是问题的话,这应该也可以作为一种不错的网页版实现方式。代码如下,感觉再稍微花点时间(大雾)改一下,应该也可以直接嵌入这个项目的机器人里面,作为一种替代/alternative。剩下担心的是,这种playwright放不方便写入一键部署的程序里。感觉,相较于对协议进行破解,这种方法更加稳定一些,就像我在go-cqhttp的readme和readme中链接的一份文档里看到的,作者觉得以后qqbot是hook时代,例如open shamrock。那这种有网页版的,不管怎么加密,至少也得让浏览器能使用吧。不过,反爬虫和反反爬虫之间的斗争,也不一定比协议少,虽然我这个反检测的代码还是11年stack overflow上“拿来”的。

import time
import asyncio
import json
from playwright.async_api import async_playwright

async def main():
    async  with (async_playwright() as p):
        browser = await p.chromium.launch(headless=False, channel="msedge")
        content = await browser.new_context()

        await content.add_init_script(
            """
                Object.defineProperty(Navigator.prototype, 'webdriver', {
                    set: undefined,
                    enumerable: true,
                    configurable: true,
                    get: new Proxy(
                        Object.getOwnPropertyDescriptor(Navigator.prototype, 'webdriver').get,
                        { apply: (target, thisArg, args) => {
                            // emulate getter call validation
                            Reflect.apply(target, thisArg, args);
                            return false;
                        }}
                    )
                });
            """
        )

        page = await content.new_page()
        cookiedict = [
            {'name': 'BAIDUID',
             'value': 'YOUR BAIDUID',
             'domain': 'yiyan.baidu.com',
             'path': '/'},
            {'name': 'BDUSS',
             'value': 'YOUR BDUSS',
             'domain': 'yiyan.baidu.com',
             'path': '/'}]

        await content.add_cookies(cookiedict)
        await page.goto("https://yiyan.baidu.com/")
        # 用于测试是否绕过了检测的网站
        # await page.goto("https://bot.sannysoft.com/")

        # 显式的定位
        # dialogue_input=await page.get_by_placeholder("请输入问题")
        # await dialogue_input.fill("晚上好")
        # await dialogue_input.press("Enter")
        dialogue_input = page.locator('textarea.ant-input')
        await dialogue_input.fill("已经是新的一天了哦!")
        await dialogue_input.press("Enter")
        res_text=''
        async with page.expect_response("https://yiyan.baidu.com/eb/chat/conversation/v2") as rep:

            response=await rep.value
            print(await response.text())
            res_text=await response.text()
        dealt_text=res_text.strip().split('\n')
        last_line=''
        for line in reversed(dealt_text):
            if line.startswith('event'):
                if line!='event:quesRecommend':
                    break;
            else:
                last_line=line
        json_dict=json.dumps(last_line.replace("data:",''))
        print(json_dict)

        print("start")
        texts = await page.evaluate(
            '''
            let res=document.getElementsByClassName('custom-html')
            let texts=new Array(res.length)
            for(let i=0;i<texts.length;i++){
                texts[i]=res[i].textContent
            }
            texts
            '''
        )
        print("执行到这了")
        print(texts)
        print(texts[-1])
        time.sleep(1000)
        await browser.close()

asyncio.run(main())