Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]爬取到有的用户的最后一条作品时,发现并不会结束寻找 #278

Open
QuoVadis86 opened this issue Feb 18, 2025 · 2 comments
Labels
等待反馈(feedback) 需要补充信息或配合测试(Feedbackers are required to add information or cooperate with the test) 无效(invalid) 非代码故障导致错误或异常(Non-code faults causing errors or anomalies)

Comments

@QuoVadis86
Copy link

描述DouyinHandler.fetch_user_post_videos(self.sec_user_id, 1679049573000, 10, 10) 时,发现在提取这个用户时,发现到了他最后一个视频所在的Max_cursor页面时(可以查看下面的日志信息),并没有结束下载。通过下面日志查看id 为 7202192422456020280的作品,通过日期筛选主页作品,发现该作品已经是该博主最后一条视频了,但是该函数并没有结束下载,而是持续往后寻找作品,无法退出while 循环。保存发现,发现video的has_more属性并没有变成false,导致他继续往最后一条作品的发布时间前面面继续寻找视频。由于已经没有作品了,count达不到Max_count导致无法退出while循环

预期行为
希望可以修复这个由于抖音api结果导致的bug

屏幕截图
Image

日志文件
开始爬取用户:MS4wLjABAAAAqVd8Rxg7hQNvtvIoPk3aea8dQm-0_qC-GbO27y8pZTE 发布的作品
2025/02/18 15:01:57 PM [DEBUG] ===================================
2025/02/18 15:01:57 PM [DEBUG] 最大数量:10 每次请求数量:10
2025/02/18 15:01:57 PM [INFO] 开始爬取第 1679049573000 页
2025/02/18 15:01:58 PM [DEBUG] 当前请求的max_cursor:1679049573000
2025/02/18 15:01:58 PM [DEBUG] 作品ID:['7209984915507514680', '7208883641751964965', '7208507606183333180', '7207763670816804156', '7206659210749168955', '7206290167043214653', '7204425326649216317', '7202192422456020280'] 作品文案:['没想到豆腐这样做_外酥里嫩太香了_比肉还好吃#豆腐丸子', '孩子想吃炸鸡腿_自己在家做好吃又卫生#在家做美食_#家常菜_#炸鸡腿', '糖醋里脊肉好不好吃_关键这几步#在家做美食_#糖醋里脊_#美食', '想要做出饭店大厨的豉汁蒸排骨_只需要几步简单的操作就可以了#豉汁蒸排骨_#在家做美食', '真没想到金针菇这样做竟然如此美味_一上桌就被吃光了#在家做美食_#蒜蓉金针菇_#蒜蓉酱', '三分钟就能做出好吃的土豆饼_酥香美味_当做早餐晚餐都很绝_#土豆饼_#煎饼_#煎饼粉_#土豆丝饼', '下班回家不想炒菜_来一碗懒人焖饭吧_饭菜一锅出_简单又营养#电饭煲美食_#懒人焖饭', '小朋友都是爱吃的芒果牛奶布丁_自己在家做干净卫生#自制果冻_#芒果布丁_#水果果冻'] 作者:['情感语录_', '情感语录_', '情感语录_', '情感语录_', '情感语录_', '情感语录_', '情感语录_', '情感语录_']
2025/02/18 15:01:58 PM [DEBUG] ===================================
2025/02/18 15:01:58 PM [INFO] 等待 5 秒后继续
2025/02/18 15:02:03 PM [DEBUG] ===================================
2025/02/18 15:02:03 PM [DEBUG] 最大数量:10 每次请求数量:2
2025/02/18 15:02:03 PM [INFO] 开始爬取第 1668472227000 页
2025/02/18 15:02:03 PM [INFO] 第 1668472227000 页没有找到作品
2025/02/18 15:02:03 PM [DEBUG] ===================================
2025/02/18 15:02:03 PM [DEBUG] 最大数量:10 每次请求数量:2
2025/02/18 15:02:03 PM [INFO] 开始爬取第 1668324791000 页
2025/02/18 15:02:04 PM [INFO] 第 1668324791000 页没有找到作品
2025/02/18 15:02:04 PM [DEBUG] ===================================
2025/02/18 15:02:04 PM [DEBUG] 最大数量:10 每次请求数量:2
2025/02/18 15:02:04 PM [INFO] 开始爬取第 1668149553000 页
2025/02/18 15:02:05 PM [INFO] 第 1668149553000 页没有找到作品
2025/02/18 15:02:05 PM [DEBUG] ===================================
2025/02/18 15:02:05 PM [DEBUG] 最大数量:10 每次请求数量:2
2025/02/18 15:02:05 PM [INFO] 开始爬取第 1668038472000 页
2025/02/18 15:02:05 PM [INFO] 第 1668038472000 页没有找到作品
2025/02/18 15:02:05 PM [DEBUG] ===================================
2025/02/18 15:02:05 PM [DEBUG] 最大数量:10 每次请求数量:2
2025/02/18 15:02:05 PM [INFO] 开始爬取第 1667893366000 页
2025/02/18 15:02:06 PM [INFO] 第 1667893366000 页没有找到作品
2025/02/18 15:02:06 PM [DEBUG] ===================================
2025/02/18 15:02:06 PM [DEBUG] 最大数量:10 每次请求数量:2
2025/02/18 15:02:06 PM [INFO] 开始爬取第 1667810464000 页
。。。。。。。。。

@QuoVadis86 QuoVadis86 added the 故障(bug) 代码问题导致的错误(Bugs caused by code problems) label Feb 18, 2025
Copy link

dosubot bot commented Feb 18, 2025

@QuoVadis86 你好!我是Dosu,我是一个可以帮助你解决bug、回答问题并成为贡献者的机器人。我会在等待人类维护者的期间帮助你。期待和你一起解决问题!🤖

I found a similar open issue that might be relevant to your problem. The issue suggests that the termination condition in the code might be incorrect. The proposed solution is to change the condition to:

if not video.hasMore and str(video.api_status_code) == "10101":

This adjustment allows the process to stop normally when there are no more videos to fetch [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@Johnserf-Seed
Copy link
Owner

Johnserf-Seed commented Feb 19, 2025

不可能去兼容错误的接口内容,你可以调整下面2个参数进一步测试。
调整interval参数限制作品时间区间例如2024-02-19|2023-02-01、调整page_counts每页返回作品数量,因为作品页码是毫秒时间戳,增大page_counts值会减少翻页次数。

@Johnserf-Seed Johnserf-Seed added 等待反馈(feedback) 需要补充信息或配合测试(Feedbackers are required to add information or cooperate with the test) 无效(invalid) 非代码故障导致错误或异常(Non-code faults causing errors or anomalies) and removed 故障(bug) 代码问题导致的错误(Bugs caused by code problems) labels Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
等待反馈(feedback) 需要补充信息或配合测试(Feedbackers are required to add information or cooperate with the test) 无效(invalid) 非代码故障导致错误或异常(Non-code faults causing errors or anomalies)
Projects
None yet
Development

No branches or pull requests

2 participants