json Puppeteer abrir varios navegadores
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了json Puppeteer abrir varios navegadores相关的知识,希望对你有一定的参考价值。
const puppeteer = require("puppeteer");
const enderecoDoSite =
"https://www.ingressorapido.com.br/event/30604-1/d/58317";
let scrape = async (user, pass) => {
const browser = await puppeteer.launch({
headless: false,
args: ["--no-sandbox", "--disable-setuid-sandbox"]
});
// const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
await page.goto(enderecoDoSite);
await page.evaluate(() => {
document
.querySelectorAll(
".item.card.selectable.style-scope.event-offers > div > span"
)
.forEach(element => {
console.log("TCL: scrape -> element", element);
if (!element.innerText.indexOf("Pista")) {
console.log("TCL: scrape -> element", element);
element.click();
}
});
});
await page.waitForNavigation();
await page.evaluate(() => {
document
.querySelectorAll(
".items.style-scope.price-list > .item.card span.price-list"
)
.forEach(element => {
console.log("TCL: scrape -> element", element);
if (!element.innerText.indexOf("Inteira")) {
element.parentNode.parentNode.querySelectorAll(
"select#select > option"
)[1].selected = "selected";
}
});
console.log(
'TCL: scrape -> document.querySelectorAll(".app-button-0[type=positive]")',
document.querySelectorAll(".app-button-0[type=positive]")
);
document.querySelectorAll(".app-button-0[type=positive]")[4].click();
});
// await page.click(".app-button-0[type=positive]");
// await page.select(inteira, "2");
// await page.click("span.event-offers");
// await page.click('#profile-nav-item');
// const btnComprarID = await page.evaluate(() => {
// return document.querySelector('.box_botao > a').getAttribute(data-id);
// });
// browser.close()
// return result
};
function tasks() {
return new Promise((resolve, reject) => {
// setTimeout(resolve, 100);
setTimeout(() => {
scrape();
resolve();
}, 2000);
});
}
(async () => {
for (let i = 0; i < 5; i++) {
await tasks();
console.log("Abrindo mais uma janela do navegador n:" + i);
}
})();
{
"name": "webscrapper",
"engines": {
"node": "8.10.0"
},
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"puppeteer": "^0.12.0"
}
}
以上是关于json Puppeteer abrir varios navegadores的主要内容,如果未能解决你的问题,请参考以下文章
abrir ficheros小组
text 禁用javascript,abrir链接vacion javascript
text 禁用javascript,abrir链接vacion javascript
sql 后链接apex y abrir莫代尔
text crear link apex y abrir modal
markdown Abrir camar usb con Gstreamer和VideoCapture