-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintercept.js
44 lines (31 loc) · 1.05 KB
/
intercept.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const puppeteer = require('puppeteer');
const cheerio = require('cheerio');
const fs = require('fs');
puppeteer.launch().then(async browser => {
const page = await browser.newPage();
await page.setExtraHTTPHeaders({ Referer: 'https://casino.eu' });
page.once('load', () => console.log('Page loaded!'));
page.on('response', async res => {
const url = res.url();
if (url.includes('/api/feed')) {
const jsonData = await res.json();
const textData = await res.text();
console.log('Received response from: %s', url);
// console.dir(jsonData);
// console.log('Plain text: %s', textData);
fs.writeFileSync('response.json', JSON.stringify(jsonData, null, 2));
console.log('Finished writing json data to response.json');
browser.close().then(() => {
console.log('Closing browser instance.');
});
}
});
await page.goto('https://casino.eu', {
timeout: 0,
waitUntil: 'networkidle0'
});
// await
});
// (async () => {
// const browser = await puppeteer.launch();
// })();