We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
主要是练习用于测试. 使用 Puppeteer 的 API.
配置 TypeScript 使用
tsc: npm install -g typescript
npm install -g typescript
tsconfig.json:
{ "compilerOptions": { "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "outDir": "out", /* Redirect output structure to the directory. */ "rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ "strict": true, /* Enable all strict type-checking options. */ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ } }
使用:
// main.ts import { Page, Browser, launch } from "puppeteer"; class Actions { /** * name */ public async goUrl(page: Page, url: string) { await page.goto(url); } } async function main() { const action = new Actions(); let browser: Browser = await launch({ headless: false }); let page: Page = await browser.newPage(); action.goUrl(page, "http://www.baidu.com"); } main();
编译后运行 main.js 即可打开百度首页.
main.js
参考资料:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Puppeteer learning
主要是练习用于测试. 使用 Puppeteer 的 API.
配置 TypeScript 使用
tsc:
npm install -g typescript
tsconfig.json:
使用:
编译后运行
main.js
即可打开百度首页.参考资料:
The text was updated successfully, but these errors were encountered: