1. JavaScript / Говнокод #28182

    −10

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 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! в день рубль нихуя не делая поднимаю на нем
    ее палится

    Запостил: paroljanet, 23 Мая 2022

    Комментарии (1) RSS

    Добавить комментарий