feat(route/baidu): add BAIDU_COOKIE support and extract shared …#21663
Open
FlanChanXwO wants to merge 10 commits intoDIYgod:masterfrom
Open
feat(route/baidu): add BAIDU_COOKIE support and extract shared …#21663FlanChanXwO wants to merge 10 commits intoDIYgod:masterfrom
FlanChanXwO wants to merge 10 commits intoDIYgod:masterfrom
Conversation
…a routes and implement user post retrieval
… handling in forum, post, search, and user routes
… formatting - Refactor parseBaiduCookies function to use chained array methods for better readability - Simplify cookie parsing by trimming and filtering empty strings before mapping - Remove redundant comments in common.ts and post.tsx files - Improve code formatting by removing excessive blank lines - Maintain same functionality while enhancing code maintainability
…utilities Add common.ts for cookie parsing, page retrieval, security check and URL normalization. Refactor forum, post, search and user routes to use shared utilities. Preserve rich text content in post replies. Support direct reply links. Fix cookie value parsing for cookies containing '=' character. Route/baidu
- Remove trailing whitespace from empty lines - Ensure consistent line endings in utility functions
# Conflicts: # lib/routes/baidu/tieba/utils.ts
Contributor
|
Successfully generated as following: http://localhost:1200/baidu/tieba/forum/good/孙笑川 - Failed ❌http://localhost:1200/baidu/tieba/post/10620724314 - Failed ❌http://localhost:1200/baidu/tieba/user/斗鱼游戏君 - Failed ❌http://localhost:1200/baidu/tieba/search/反原神 - Failed ❌ |
Contributor
|
Successfully generated as following: http://localhost:1200/baidu/tieba/forum/good/孙笑川 - Failed ❌http://localhost:1200/baidu/tieba/post/10620724314 - Failed ❌http://localhost:1200/baidu/tieba/user/斗鱼游戏君 - Failed ❌http://localhost:1200/baidu/tieba/search/反原神 - Failed ❌ |
…ontent retrieval (#2)
Contributor
|
Successfully generated as following: http://localhost:1200/baidu/tieba/forum/good/孙笑川 - Failed ❌http://localhost:1200/baidu/tieba/post/10620724314 - Failed ❌http://localhost:1200/baidu/tieba/user/斗鱼游戏君 - Failed ❌http://localhost:1200/baidu/tieba/search/反原神 - Failed ❌ |
Contributor
|
Successfully generated as following: http://localhost:1200/baidu/tieba/forum/good/孙笑川 - Failed ❌http://localhost:1200/baidu/tieba/post/10620724314 - Failed ❌http://localhost:1200/baidu/tieba/user/斗鱼游戏君 - Failed ❌http://localhost:1200/baidu/tieba/search/反原神 - Failed ❌ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Involved Issue / 该 PR 相关 Issue
Close #19642
Example for the Proposed Route(s) / 路由地址示例
New RSS Route Checklist / 新 RSS 路由检查表
PuppeteerNote / 说明
概述
本次 PR 为百度贴吧的 4 个路由(
/baidu/tieba/forum、/baidu/tieba/post、/baidu/tieba/search、/baidu/tieba/user)添加了 BAIDU_COOKIE 支持,以应对百度反爬机制的升级。主要改动
从 HTTP 请求迁移到 Puppeteer
got/ofetch直接发送 HTTP 请求获取页面内容新增
common.ts共享模块parseBaiduCookies(): 正确解析包含=字符的 Cookie 值getTiebaPageContent(): 统一的页面获取逻辑,包含 Cookie 注入和安全验证检查normalizeUrl(): 将相对链接转换为绝对地址checkSecurityVerification(): 检测百度安全验证页面并抛出友好错误提示各路由适配
.thread-card选择器改进时间解析
parseRelativeTime()支持更多格式(刚刚、昨天、X天前等)必需配置
以下 4 个路由现在必须配置
BAIDU_COOKIE才能使用:/baidu/tieba/forum/:kw/baidu/tieba/forum/女图/baidu/tieba/post/:id/baidu/tieba/post/686961453/baidu/tieba/search/:qw/baidu/tieba/search/neuro/baidu/tieba/user/:uid/baidu/tieba/user/斗鱼游戏君配置方法
在环境变量或
.env文件中设置:BAIDU_COOKIE=BDUSS=your_bduss_value;other_cookie=value