puppeteer set header

Solutions on MaxInterview for puppeteer set header by the best coders in the world

showing results for - "puppeteer set header"
Emanuele
17 Aug 2016
1await page.setExtraHTTPHeaders({
2        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36',
3        'upgrade-insecure-requests': '1',
4        'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
5        'accept-encoding': 'gzip, deflate, br',
6        'accept-language': 'en-US,en;q=0.9,en;q=0.8'
7    })
8await page.goto('...')
9
Emilia
13 Feb 2016
1	await page.setRequestInterception(true)	await page.setRequestInterception(true)
2		await page.on('request', (req) => {
3			if (!req.isNavigationRequest()) {
4				req.continue()
5				return
6			}
7
8			const headers = req.headers()
9			headers['Access-Control-Allow-Origins'] = '*'
10			headers['Accept'] = 'application/json'
11			headers['Accept-Encoding'] = 'gzip, br'
12			headers['Content-Type'] = 'application/json'
13			headers['Cache-Control'] = 'no-cache'
14			headers['User-Agent'] = 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:15.0) Gecko/20100101 Firefox/15.0.1'
15
16			req.continue({ ...headers })
17		})
18		await page.on('request', (req) => {
19			if (!req.isNavigationRequest()) {
20				req.continue()
21				return
22			}
23
24			const headers = req.headers()
25			headers['Access-Control-Allow-Origins'] = '*'
26			headers['Accept'] = 'application/json'
27			headers['Accept-Encoding'] = 'gzip, br'
28			headers['Content-Type'] = 'application/json'
29			headers['Cache-Control'] = 'no-cache'
30			headers['User-Agent'] = 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:15.0) Gecko/20100101 Firefox/15.0.1'
31
32			req.continue({ ...headers })
33		})
Julia
29 May 2020
1await this.page.setExtraHTTPHeaders({
2	'Accept-Language': 'en-US'
3});