liyong
昨天 d42f9256b4aab375b6c7897e11e99f07bf5f9c95
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const { chromium } = require('playwright');
 
(async () => {
  try {
    // 启动浏览器(使用持久化上下文以使用已登录的会话)
    const browser = await chromium.launch({ headless: false });
    console.log('浏览器已启动');
 
    const context = await browser.newContext();
    const page = await context.newPage();
 
    // 访问腾讯文档
    console.log('正在访问腾讯文档...');
    await page.goto('https://docs.qq.com/sheet/DWWVMTEVSa1dVb3BF?tab=ggdtuh', {
      waitUntil: 'networkidle',
      timeout: 60000
    });
 
    // 等待页面加载
    await page.waitForTimeout(5000);
 
    const title = await page.title();
    console.log(`页面标题: ${title}`);
    console.log(`当前URL: ${page.url()}`);
 
    // 尝试获取页面内容
    const content = await page.content();
    console.log('\n页面内容长度:', content.length);
 
    // 截图保存
    await page.screenshot({ path: 'screenshot.png', fullPage: true });
    console.log('截图已保存到 screenshot.png');
 
    // 等待用户查看
    await page.waitForTimeout(10000);
 
    await browser.close();
  } catch (error) {
    console.error('错误:', error.message);
  }
})();