-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbet.js
42 lines (30 loc) · 921 Bytes
/
bet.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
const PUPPETEER_OPTS = {
headless: false,
slowMo: { default: 300, click: 200, keyup: 10 },
devtools: true,
}
var events = require('events');
var eventEmitter = new events.EventEmitter();
function gabi(globalVar, eventEmitter){
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch(PUPPETEER_OPTS)
const page = await browser.newPage()
await page.goto('https://www.google.es')
page.exposeFunction('puppeteerMutationListener', function(value){
eventEmitter.emit('changeData',value);
});
globalVar.a=await page.evaluate(element => {
alert('ha funcionado');
})
})()
}
let paramToSaveData={};
eventEmitter.on('changeData',(value) => {
for(let i in value){
paramToSaveData[i]=value[i];
}
console.log('evento',value)
console.log('dato',paramToSaveData);
});
gabi(paramToSaveData,eventEmitter);