How to use the launch function from puppeteer

Find comprehensive JavaScript puppeteer.launch code examples handpicked from public code repositorys.

49
50
51
52
53
54
55
56
57
58
59
60
  address = family === 'IPv6' ? `[${address}]` : address
  return `http://${address}:${port}`
}


const download = async (baseDir, url) => {
  const browser = await puppeteer.launch()
  const page = await browser.newPage()
  const urls = []


  page.on('request', (request) => {
fork icon31
star icon938
watch icon25

+ 8 other calls in file

32
33
34
35
36
37
38
39
40
41
    args.push('--proxy-server=' + configuration.getOption('proxy'));
}

logger.info("Launching browser with args:");
logger.info(args);
browser = await puppeteer.launch({
    args: args,
    ignoreHTTPSErrors: true,

});
fork icon23
star icon90
watch icon13

+ 8 other calls in file

180
181
182
183
184
185
186
187
188
189
	});
},

prepareBrowser: function(options) {
	options = _.defaults({}, options || {}, manager.defaultBrowserOptions);
	return puppeteer.launch(options).then(browser => {
		const context = browser.defaultBrowserContext();
		context.overridePermissions(this.getUrl(), ['clipboard-read']);
		manager.browser = browser;
	});
fork icon8
star icon28
watch icon0

6
7
8
9
10
11
12
13
14
15
16
        target: 'pino-pretty'
    }
});


(async () => {
    const browser = await puppeteer.launch({
        headless: true,
        ignoreHTTPSErrors: true,
        devtools: false,
        defaultViewport: null,
fork icon21
star icon13
watch icon9

+ 18 other calls in file

440
441
442
443
444
445
446
447
448
449
    }
});

// it("refresh session via reading of frontend info using fetch", async function () {
//     await startST();
//     const browser = await puppeteer.launch({
//         args: ["--no-sandbox", "--disable-setuid-sandbox"]
//     });
//     try {
//         const page = await browser.newPage();
fork icon12
star icon45
watch icon7

+ 835 other calls in file

625
626
627
628
629
630
631
632
633
634
		'--no-sandbox',
		"--shm-size=8gb",
		"--disk-cache-size=0",
		"--media-cache-size=0"
);
var browser = await puppeteer.launch({
	headless: true,
	args: args,
	'ignoreHTTPSErrors': true
});
fork icon6
star icon32
watch icon2

+ 5 other calls in file

11
12
13
14
15
16
17
18
19
20
const testExtensionPath = path.join(
    __dirname, 'test', 'data', 'chrome-extension'
)

// Open the browser, installing the test extension.
this.browser = await puppeteer.launch({
    headless: 'chrome',
    args: [
        '--disable-extensions-except=' + testExtensionPath,
        '--load-extension=' + testExtensionPath
fork icon3
star icon5
watch icon19

+ 5 other calls in file

104
105
106
107
108
109
110
111
112
113
    const browserArgs = [...(puppeteerOpts.args || [])];
    if (!browserArgs.find(arg => arg.includes('--user-agent'))) {
        browserArgs.push(`--user-agent=${this.options.userAgent}`);
    }

    browser = await puppeteer.launch({ ...puppeteerOpts, args: browserArgs });
    page = (await browser.pages())[0];
}

await page.setUserAgent(this.options.userAgent);
fork icon1
star icon5
watch icon0

73
74
75
76
77
78
79
80
81
}

async init({ profileId }) {
	//! DEVONLY
	// {
	// 	this.browser = await puppeteer.launch({
	// 		headless: false,
	// 		args: [/* '--disable-web-security', '--disable-features=IsolateOrigins,site-per-process', */ '--window-size=1280,720'],
	// 	});
fork icon0
star icon3
watch icon0

22
23
24
25
26
27
28
29
30
31
32
/**
 * Start the browser in the background, takes max. 20 seconds to load, no command shall not be ran in the meantime.
 * @returns undefined
 */
async function startProcess() {
	browser = await puppeteer.launch({ headless: true });
	page = await browser.newPage();


	await page.setViewport({
		width: 1920,
fork icon0
star icon2
watch icon2

+ 10 other calls in file

36
37
38
39
40
41
42
43
44
45
46
47
48
    }


}


async function checkinternet() {
    const browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox'] })


    page = await browser.newPage();
    await page.goto(url, { waitUntil: 'domcontentloaded' });

fork icon0
star icon2
watch icon0

46
47
48
49
50
51
52
53
54
55
    ignoreHTTPSErrors: true
};
if (proxyConfig != null) {
    browserConfig.args.push('--proxy-server=' + proxyConfig.url);
}
const browser = await puppeteer.launch(browserConfig);
const page = await browser.newPage();
await page.setUserAgent(userAgent);
if (proxyConfig != null) {
    await page.authenticate({
fork icon2
star icon1
watch icon0

6
7
8
9
10
11
12
13
14
15
16
17


const util = require('./util.js');


async function startContext() {
  if (!util.dryrun) {
    let context = await puppeteer.launch({
      args: util['browserArgs'].split(' '),
      defaultViewport: null,
      executablePath: util['browserPath'],
      headless: false,
fork icon3
star icon0
watch icon6

+ 25 other calls in file

37
38
39
40
41
42
43
44
45
if (proxy) {
  const proxyUrl = new URL(proxy)
  pupOpts['args'].push(`--proxy-server=${proxyUrl.origin}`)
}

this.instance = await puppeteer.launch(this.pupOpts)
logger.info('browser is created')

this.isLockBrowser = false
fork icon1
star icon1
watch icon0

20
21
22
23
24
25
26
27
28
29
30
31
32
      .then(async ([rows]) => {
        rowsDB.push(...rows)
      })
  })


 const browser = await puppeteer.launch();


const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];


const uniqueArray = [];
fork icon1
star icon1
watch icon0

134
135
136
137
138
139
140
141
142
143
        '--disable-setuid-sandbox'
    ],
    ignoreDefaultArgs: ["--hide-scrollbars"]*/
};

const browser = await puppeteer.launch(browserOptions);
const page = await browser.newPage();

var allData = [];
var token;
fork icon0
star icon1
watch icon2

+ 21 other calls in file

27
28
29
30
31
32
33
34
35
36
  return res.status(400).send({ error: 'URL is required.' });
}

try {
  console.log('Opening URL: ', url);
  browser = await puppeteer.launch({ headless: false });
  page = await browser.newPage();
  await page.goto(url);

  return res.status(200).send({ message: 'URL opened successfully.' });
fork icon0
star icon1
watch icon0

+ 2 other calls in file

28
29
30
31
32
33
34
35
36
37
38
39
    '--proxy-pac-url=data:application/x-ns-proxy-autoconfig;base64,'+PAC_B64,
  ];
}


(async function(){
  const browser = await puppeteer.launch(puppeter_args);


  function ask_for_url(socket) {
      socket.state = 'URL';
      socket.write('Please send me a URL to open.\n');
fork icon0
star icon1
watch icon0

25
26
27
28
29
30
31
32
33
34
35
    }))
}


async function scrapExpansions() {
    console.log('Scraping expansions...');
    const browser = await puppeteer.launch({ headless: true });
    const page = await browser.newPage();
    page.setDefaultTimeout(60000);
    page.setDefaultNavigationTimeout(60000);
    await page.goto(__EXPANSIONS_BASE_URL__);
fork icon0
star icon2
watch icon1

+ 74 other calls in file

926
927
928
929
930
931
932
933
934
935
936
937
938


async function run() {
	let start = true;


	log("START ", account, new Date().toLocaleString());
	const browser = await puppeteer.launch(puppeteer_options);


	//const page = await browser.newPage();
	let [page] = await browser.pages();

fork icon1
star icon1
watch icon1

+ 16 other calls in file