ReaJason / xhs

基于小红书 Web 端进行的请求封装。https://reajason.github.io/xhs/
MIT License
1.03k stars 295 forks source link

playwright._impl._api_types.Error: Execution context was destroyed, most likely because of a navigation #39

Closed WdBlink closed 1 year ago

WdBlink commented 1 year ago

脚本中只修改了 cokkie,设置了a1,webID,web_session三个参数,有以下报错: python example/basic_usage.py Traceback (most recent call last): File "/Users/echooo/Documents/Code/my_repo/周末计划生成器/xhs/example/basic_usage.py", line 50, in note_info = xhs_client.get_note_by_id("64c27f08000000001701967a") File "/opt/homebrew/lib/python3.9/site-packages/xhs/core.py", line 201, in get_note_by_id res = self.post(uri, data) File "/opt/homebrew/lib/python3.9/site-packages/xhs/core.py", line 187, in post self._pre_headers(uri, data, is_creator=is_creator) File "/opt/homebrew/lib/python3.9/site-packages/xhs/core.py", line 155, in _pre_headers self.sign( File "/Users/echooo/Documents/Code/my_repo/周末计划生成器/xhs/example/basic_usage.py", line 31, in sign encrypt_params = context_page.evaluate( File "/opt/homebrew/lib/python3.9/site-packages/playwright/sync_api/_generated.py", line 8698, in evaluate self._sync( File "/opt/homebrew/lib/python3.9/site-packages/playwright/_impl/_sync_base.py", line 109, in _sync return task.result() File "/opt/homebrew/lib/python3.9/site-packages/playwright/_impl/_page.py", line 395, in evaluate return await self._main_frame.evaluate(expression, arg) File "/opt/homebrew/lib/python3.9/site-packages/playwright/_impl/_frame.py", line 277, in evaluate await self._channel.send( File "/opt/homebrew/lib/python3.9/site-packages/playwright/_impl/_connection.py", line 61, in send return await self._connection.wrap_api_call( File "/opt/homebrew/lib/python3.9/site-packages/playwright/_impl/_connection.py", line 482, in wrap_api_call return await cb() File "/opt/homebrew/lib/python3.9/site-packages/playwright/_impl/_connection.py", line 97, in inner_send result = next(iter(done)).result() playwright._impl._api_types.Error: Execution context was destroyed, most likely because of a navigation

ReaJason commented 1 year ago

请问是概率事件,还是一直这样报错无法使用,如果是概率事件的话,可以自行添加异常捕获代码,我这无法复现这个错误,如果能稳定复现的话,麻烦提供代码和执行环境,感谢反馈。

WdBlink commented 1 year ago

概率事件,早起又好了

ReaJason commented 1 year ago

加个重试好了,请尝试用最新的 basic_usage.py