Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const puppeteer = require('puppeteer');
- setInterval(()=>{
- (async () => {
- const browser = await puppeteer.launch({headless: false});
- const page = await browser.newPage();
- const url='https://adfslight.oswiatawradomiu.pl/LoginPage.aspx?ReturnUrl=%2f%3fwa%3dwsignin1.0%26wtrealm%3dhttps%253A%252F%252Fsynergia.librus.pl%252Floguj%252Fradom';
- await page.goto(url);
- await page.type('#Username', 'j');
- await page.type('#Password', 'd');
- await page.click('.submit-button');
- await page.waitForNavigation();
- await page.waitForNavigation();
- await page.goto('https://synergia.librus.pl/wiadomosci');
- //await page.screenshot({path: 'example.png'});
- e = await page.evaluate(() => {
- const messages = [];
- const unreadQuery = '.container-background > table > tbody > tr > td:nth-child(2n) > table:nth-child(2n) > tbody'+'> tr > td[style="font-weight: bold;"] ';
- // const clickList = document.querySelectorAll(unreadQuery + '> a');
- const messList = document.querySelectorAll(unreadQuery);
- messList.forEach((el, i) => {
- if(i%3==0) messages.push( {
- author: el.innerText,
- title: "",
- date: ""
- } );
- else if(i%3==1) messages[messages.length-1].title = el.innerText;
- else messages[messages.length-1].date = el.innerText;
- });
- return{
- messages
- }
- })
- for(let i=0;i<e.messages.length;i++){
- await page.click('.container-background > table > tbody > tr > td:nth-child(2n) > table:nth-child(2n) > tbody'+'> tr > td[style="font-weight: bold;"] '+' > a');
- await page.screenshot({path: `test${i}.jpg`, fullPage: true})
- await page.goBack();
- }
- await browser.close();
- const Time = new Date();
- console.log(`Jest ${Time.getHours}:${Time.getMinutes}:${Time.getSeconds} ${Time.getUTCDate}`);
- console.log(`Program odczytał ${e.messages.length} następujących wiadomości:`);
- e.messages.forEach(el=>{
- console.log(`${el.author}||${el.title}||${el.data}`);
- });
- });
- }, 300);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement