Files
media-center/sites/yunpan1/v1/usage.md
T
sutong 3fced32625 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>
2026-05-16 21:44:37 +08:00

2.6 KiB

yunpan1 — 获取资源

使用 Playwright 浏览器完成搜索、查看帖子、回复获取隐藏链接。

前置检查

浏览器可能已登录 yunpan1,先检查登录状态:

const text = await page.evaluate(() => document.body.innerText);
const loggedIn = !text.includes('登录发现更多内容');

未登录时先登录:

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"] button[name="loginsubmit"]').click();

搜索

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()]
  };
});

查看帖子详情

截断的链接需打开帖子查看。帖子有回复可见机制时,先回复再刷新:

// 打开帖子
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&orderby=dateline

拿到链接后的操作

夸克链接转存流程见 storage/quark/v1/usage.md