使用 nodejs 和 puppeteer,它看起来像:
const puppeteer = require('puppeteer');
const browser = await puppeteer.launch();
const page1 = await browser.newPage();
await page1.goto('https://google.com');
await page1.waitForSelector('#fsl > a:nth-child(4)');
const link = await page1.$('#fsl > a:nth-child(4)');
const newPagePromise = new Promise(x => browser.once('targetcreated', target => x(target.page()))); // define promise
await link.click({button: 'middle'});
const page2 = await newPagePromise;
await page2.bringToFront();
...
await browser.close();
python和pyppeteer的等效代码字符串“定义承诺”是什么?