blob: a75ba3dbac3cc4d9ad9ae27a42d77800c80158b5 (
plain)
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
|
const puppeteer = require('puppeteer');
(async () => {
// 第一引数からURLを取得
const url = process.argv[2];
if (!url) {
console.error('Error: URL not provided.');
process.exit(1);
}
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
// 特定のURLにアクセス
await page.goto(url, {
waitUntil: 'networkidle2', // ネットワークがアイドル状態になるまで待機
});
// 5秒間待機
await page.waitForTimeout(5000);
// ページのHTMLを取得
const html = await page.content();
console.log(html);
await browser.close();
})();
|