Files
media-center/sites/yunpan1/v1/usage.md
T
sutong af5059c585 docs: add yunpan1 captcha handling
- usage.md: 增加验证码弹窗处理步骤,验证码 392718

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-16 21:48:20 +08:00

2.9 KiB

yunpan1 — 获取资源

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

验证码

网站有时弹窗要求输入验证码。检测到输入框时填入:

const captchaInput = page.locator('input[placeholder*="验证码"]');
if (await captchaInput.isVisible()) {
  await captchaInput.fill('392718');
  await page.locator('button:has-text("提交")').click();
  await page.waitForTimeout(2000);
}

前置检查

浏览器可能已登录 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