refactor: yunpan1 full Playwright workflow (verified)
- 删除 yunpan1_search.py(Python 不稳定) - 删除 tmp/yunpan1_cookies.txt - usage.md: Playwright 完整流程(登录→搜索→回复→获取链接) - 全部步骤经 Playwright 实机验证 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+69
-36
@@ -1,51 +1,84 @@
|
||||
# yunpan1 — 获取资源
|
||||
|
||||
## Python 脚本搜索(推荐)
|
||||
使用 Playwright 浏览器完成搜索、查看帖子、回复获取隐藏链接。
|
||||
|
||||
依赖:Python 标准库(无需额外安装)
|
||||
## 前置检查
|
||||
|
||||
```bash
|
||||
py -X utf8 sites/yunpan1/v1/yunpan1_search.py <关键词>
|
||||
```
|
||||
|
||||
示例:
|
||||
|
||||
```bash
|
||||
py -X utf8 sites/yunpan1/v1/yunpan1_search.py 遮天
|
||||
py -X utf8 sites/yunpan1/v1/yunpan1_search.py 完美世界
|
||||
```
|
||||
|
||||
搜索结果:
|
||||
- **完整夸克链接**(12 位 ID,可直接转存到夸克网盘)
|
||||
- **被截断的链接**(部分帖子在搜索结果中截断了链接,需点进帖子查看)
|
||||
- 链接自动保存到 `tmp/quark_links.txt`
|
||||
|
||||
首次搜索因 Discuz! 后端建索引可能等待 1-2 分钟,同一关键词后续秒回。
|
||||
|
||||
## Cookie 维护
|
||||
|
||||
搜索需要登录态,Cookie 保存在 `tmp/yunpan1_cookies.txt`,约 1 天过期。
|
||||
|
||||
Cookie 过期后通过 Playwright 重新登录获取:
|
||||
浏览器可能已登录 yunpan1,先检查登录状态:
|
||||
|
||||
```javascript
|
||||
const text = await page.evaluate(() => document.body.innerText);
|
||||
const loggedIn = !text.includes('登录发现更多内容');
|
||||
```
|
||||
|
||||
未登录时先登录:
|
||||
|
||||
```javascript
|
||||
// Playwright 登录流程
|
||||
await page.goto('https://yunpan1.cc/member.php?mod=logging&action=login');
|
||||
await page.locator('form[name="login"] input[name="username"]').fill('向用户索要邮箱');
|
||||
await page.locator('form[name="login"] input[name="password"]').fill('向用户索要密码');
|
||||
await page.locator('form[name="login"] input[name="username"]').fill('账号');
|
||||
await page.locator('form[name="login"] input[name="password"]').fill('密码');
|
||||
await page.locator('form[name="login"] button[name="loginsubmit"]').click();
|
||||
// 等待跳转回首页确认登录成功
|
||||
|
||||
// 提取 Cookie 保存到文件
|
||||
const cookies = await page.context().cookies();
|
||||
// 关键 Cookie: 2dF6_2132_auth, 2dF6_2132_saltkey, 2dF6_2132_lastvisit
|
||||
```
|
||||
|
||||
## 直接浏览板块
|
||||
## 搜索
|
||||
|
||||
```javascript
|
||||
await page.goto('https://yunpan1.cc/search.php?mod=forum&srchtxt=' + encodeURIComponent('关键词') + '&searchsubmit=yes');
|
||||
await page.waitForTimeout(3000);
|
||||
|
||||
const data = await page.evaluate(() => {
|
||||
const text = document.body.innerText;
|
||||
const links = text.match(/https?:\/\/pan\.quark\.cn\/s\/[a-zA-Z0-9]+/g) || [];
|
||||
const threads = Array.from(document.querySelectorAll('a[href*="viewthread"]'));
|
||||
const titles = threads.map(a => ({ title: a.innerText.trim(), url: a.href }));
|
||||
return {
|
||||
links: [...new Set(links)],
|
||||
threads: [...new Map(titles.filter(t => t.title.length > 5).map(t => [t.title, t])).values()]
|
||||
};
|
||||
});
|
||||
```
|
||||
|
||||
## 查看帖子详情
|
||||
|
||||
截断的链接需打开帖子查看。帖子有回复可见机制时,先回复再刷新:
|
||||
|
||||
```javascript
|
||||
// 打开帖子
|
||||
await page.goto('帖子URL');
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
// 检测是否有隐藏内容
|
||||
const hasHidden = await page.evaluate(() =>
|
||||
document.body.innerText.includes('本内容被作者隐藏')
|
||||
);
|
||||
|
||||
if (hasHidden) {
|
||||
// 点击回复按钮
|
||||
await page.getByRole('link', { name: '回复', exact: true }).first().click();
|
||||
await page.waitForTimeout(1000);
|
||||
// 填写回复内容
|
||||
await page.locator('#postmessage').fill('谢谢分享');
|
||||
// 提交回复
|
||||
await page.locator('button[name="replysubmit"]').first().click();
|
||||
await page.waitForTimeout(3000);
|
||||
// 刷新页面查看完整内容
|
||||
await page.goto('帖子URL');
|
||||
await page.waitForTimeout(2000);
|
||||
}
|
||||
|
||||
// 提取夸克链接
|
||||
const links = await page.evaluate(() => {
|
||||
const text = document.body.innerText;
|
||||
return [...new Set(text.match(/https?:\/\/pan\.quark\.cn\/s\/[a-zA-Z0-9]+/g) || [])];
|
||||
});
|
||||
```
|
||||
|
||||
## 板块浏览
|
||||
|
||||
搜索不可用时直接看动漫板块最新帖子:
|
||||
|
||||
```
|
||||
动漫:https://yunpan1.cc/forum.php?mod=forumdisplay&fid=3
|
||||
影视:https://yunpan1.cc/forum.php?mod=forumdisplay&fid=2
|
||||
https://yunpan1.cc/forum.php?mod=forumdisplay&fid=3&orderby=dateline
|
||||
```
|
||||
|
||||
## 拿到链接后的操作
|
||||
|
||||
Reference in New Issue
Block a user