- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
const puppeteer = require('puppeteer-core');
const fs = require('fs');
const getCurrentLine = require('get-current-line').default;
const { execFileSync } = require('child_process');
const data = fs.readFileSync('profitcentr.com.cookies.json');
const cookies = JSON.parse(data.toString());
function randomInteger(min, max) {
let rand = min - 0.5 + Math.random() * (max - min + 1);
return Math.round(rand);
}
function delay(time) {
return new Promise(function(resolve) {
setTimeout(resolve, time*1000)
});
}
function delay2(time) {
return new Promise(function(resolve) {
setTimeout(resolve, time)
});
}
(async () => {
const browser = await puppeteer.launch({
headless: false,
defaultViewport: null,
executablePath: '/usr/bin/chromium',
devtools: false,
args: [
'--start-maximized',
]
});
const page = await browser.newPage();
await page.setDefaultNavigationTimeout(0);
let newPage;
await page.setCookie(...cookies);
await page.goto('https://profitcentr.com', {waitUntil: 'networkidle0'});
let link = await page.$('a[href^="./work-youtube"]');
console.log('go to youtube')
await link.click();
await page.waitForTimeout(1000);
let c = 0;
while(true) {
if(c == 100) {
await page.reload({ waitUntil: ["networkidle0", "domcontentloaded"] });
c = 0;
}
let t = await page.$('[id^="ads-link-"]');
if(t == null) {
console.log('wait new tasks...');
await delay(10);
await page.reload({ waitUntil: ["networkidle0", "domcontentloaded"] });
c = 0;
continue;
}
let tt = await t.evaluate((q) => getComputedStyle(q).display);
if(tt == 'none') {
console.log('del inactive')
page.evaluate(q => { document.querySelector('[id^="ads-link-"]').remove(); })
continue;
}
let tr = await page.$('tr[class^="ads_"]');
let span = await tr.$('[onclick^="funcjs[\'start_youtube"]');
let title = await span.evaluate(el => el.textContent.trim());
console.log('title: \''+title+'\'');
let price = await tr.$('[title^="Стоимость"]');
let prices = await price.evaluate(el => el.textContent.trim());
console.log('price: ' + prices);
let newPagePromise = new Promise(x => browser.once('targetcreated', target => x(target.page())));
//await page.waitForSelector('tr[class^="ads_"] span[onclick^="funcjs[\'start_youtube"]');
//let x = await page.$('tr[class^="ads_"] span[onclick^="funcjs[\'start_youtube"]');
//console.log(x.click);
await page.waitForTimeout(1000);
try {
await page.click('tr[class^="ads_"] span[onclick^="funcjs[\'start_youtube"]');
}
catch(e) {
console.log('error! del item'); await page.evaluate(() => { document.querySelector('tr[class^="ads_"]').remove() }); continue; } await page.waitForSelector('span[onclick^="funcjs[\'open_window"]', { timeout: 60000 }); await delay2(randomInteger(700, 2000)); await page.click('span[onclick^="funcjs[\'open_window"]'); //newPage = await newPagePromise; await page.waitForTimeout(2000); let p = await browser.pages() newPage = p[2]; await newPage.bringToFront(); console.log('> '+newPage.url()); await newPage.waitForSelector('tr[id="timer-tr-block"]', { timeout: 60000 }); await delay(3); console.log('yt click'); const frame = await newPage.waitForSelector('iframe'); let rect = await newPage.evaluate(el => { let {width, height} = el.getBoundingClientRect(); return {width, height}; }, frame); await newPage.mouse.click(rect.width / 2, rect.height / 2); console.log('waiting'); await newPage.waitForSelector('[id="capcha-tr-block"][style="display: table-row;"]', { timeout: 350000 }); let btn = await newPage.$('[class="butt-nw"]'); await btn.click(); console.log('ok'); await delay2(randomInteger(900, 1500)); //console.log('> '+newPage.url()); await newPage.close(); await delay2(500); await page.bringToFront(); await page.evaluate(() => { document.querySelector('tr[class^="ads_"]').remove() }); await delay(randomInteger(1, 3)); console.log('c: '+ ++c +"\n"); } await browser.close(); })();
тупо грабер для profitcentr! в день рубль нихуя не делая поднимаю на нем
ее палится
Support 23.05.2022 12:17 # +3