gpt4 book ai didi

In Playwright,cannot keep Page.on listening cause connection closed?(在编剧中,无法保持寻呼。正在收听时是否导致连接关闭?)

转载 作者:bug小助手 更新时间:2023-10-24 19:37:11 24 4
gpt4 key购买 nike



I am trying to use Playwright to listen event in browser continuously,but it seems that if I don't use browser.close(),it cannot keep listening either.

我试着用PlayWright连续监听浏览器中的事件,但如果我不使用Browser.lose(),它似乎也无法继续监听。


with sync_playwright() as p:
browser = p.chromium.launch(headless=False)
page = browser.new_page()
page.on('response', on_response)
page.goto('https://sport.dgut.edu.cn')

after running this, Playwright exit automatically.
if I swap page.on and page.goto,it will like this:

运行此命令后,编剧会自动退出。如果我交换Page.On和Page.goto,它将如下所示:


Future exception was never retrieved
future: <Future finished exception=Error('Connection closed')>
playwright._impl._api_types.Error: Connection closed

更多回答

What's the definition for on_response and what are you really trying to accomplish here? Usually, if you're trying to wait for a particular response, you'd use page.expect_response.

On_Response的定义是什么?你在这里真正想要实现的是什么?通常,如果您正在尝试等待特定的响应,则可以使用page.expect_Response。

优秀答案推荐
更多回答

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com