ReaJason / xhs

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

该脚本发笔记,会被小红书判定限流吗? #38

Closed godJBJ closed 1 year ago

godJBJ commented 1 year ago

如题

ReaJason commented 1 year ago

不知道诶,请问这个怎么测试🫠

godJBJ commented 1 year ago

只能发笔记试试看流量正不正常了。

godJBJ commented 1 year ago

发布笔记有时候也会报错(测试有一定概率报错),如下: Traceback (most recent call last): File "D:\project\xhs-master\example\basic_usage.py", line 54, in note_info = xhs_client.create_image_note(title, desc, images, is_private=False, post_time="2023-08-03 16:06:00") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\project\xhs-master\xhs\core.py", line 783, in create_image_note return self.create_note(title, desc, NoteType.NORMAL.value, ats=ats, topics=topics, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\project\xhs-master\xhs\core.py", line 743, in create_note return self.post(uri, data, headers=headers) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\project\xhs-master\xhs\core.py", line 187, in post self._pre_headers(uri, data, is_creator=is_creator) File "D:\project\xhs-master\xhs\core.py", line 155, in _pre_headers self.sign( File "D:\project\xhs-master\example\basic_usage.py", line 29, in sign encrypt_params = context_page.evaluate("([url, data]) => window._webmsxyw(url, data)", [uri, data]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\project\xhs-master\venv\Lib\site-packages\playwright\sync_api_generated.py", line 8698, in evaluate self._sync( File "D:\project\xhs-master\venv\Lib\site-packages\playwright_impl_sync_base.py", line 109, in _sync return task.result() ^^^^^^^^^^^^^ File "D:\project\xhs-master\venv\Lib\site-packages\playwright_impl_page.py", line 395, in evaluate return await self._main_frame.evaluate(expression, arg) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\project\xhs-master\venv\Lib\site-packages\playwright_impl_frame.py", line 277, in evaluate await self._channel.send( File "D:\project\xhs-master\venv\Lib\site-packages\playwright_impl_connection.py", line 61, in send return await self._connection.wrap_api_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\project\xhs-master\venv\Lib\site-packages\playwright_impl_connection.py", line 482, in wrap_api_call return await cb() ^^^^^^^^^^ File "D:\project\xhs-master\venv\Lib\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

Process finished with exit code 1 作者大大碰到过这种情况吗?对python不是很熟看不太懂...

ReaJason commented 1 year ago

暂时不太懂 playwright 为什么会报这个错误,可以试试捕获异常然后重试。