headless browser 无头浏览器 playwright

访问量: 243

参考: https://playwright.dev/docs/intro#manually

起因

我想要nftgo.io的数据

发现这是一帮杭州人做的。。。

然后找到了这个:   checklyhq , 用python脚本抓包的

https://www.checklyhq.com/learn/headless/request-interception/

其实这个正是我想要的

然后发现了 playwright

安装

(注意先进入到工作目录)

npm i -D @playwright/test

npx playwright install

创建新的测试

注意:

1。 文件要以 .spec.js 结尾

2. 文件要放在 tests  目录下

sg552@SKYUSER-DSBR6H5:/workspace/playwright$ cat tests/example.spec.js
const { test, expect } = require('@playwright/test');

test('basic test', async ({ page }) => {
  await page.goto('https://playwright.dev/');
  const title = page.locator('.navbar__inner .navbar__title');
  await expect(title).toHaveText('Playwright');
});

运行

npx playwright test --headed
Running 1 test using 1 worker

  ok tests\example.spec.js:3:1 › basic test (15s)

  1 passed (16s)

会看到一个浏览器窗口弹出来,太NB了。

订阅/RSS Feed

Subscribe