Created
June 27, 2022 19:13
-
-
Save reepush/54d6fee22d55aa607de788f725605628 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer') | |
const urls = [ | |
'https://ticket.rzd.ru/searchresults/v/1/5a3244bc340c7441a0a556ca/5a323c29340c7441a0a556bb/2022-06-28?aim=social-media&trainNumber=759%D0%90', | |
'https://ticket.rzd.ru/searchresults/v/1/5a3244bc340c7441a0a556ca/5a323c29340c7441a0a556bb/2022-06-28?aim=social-media&trainNumber=761%D0%90', | |
] | |
const main = async () => { | |
const browser = await puppeteer.launch({ headless: false }) | |
const page = await browser.newPage() | |
while (true) { | |
for (let url of urls) { | |
await page.goto(url) | |
await page.waitForTimeout(60 * 1000) | |
const title = await page.$('.nodirect__title') | |
const card = await page.$('.card') | |
const text = await page.evaluate(() => (document.querySelector('.body__classes') || { innerText: '' }).innerText) | |
if (!title && card && text.match('Эконом')) { | |
console.log(Date()) | |
await page.goto('https://www.youtube.com/watch?v=CICIOJqEb5c') | |
await page.waitForTimeout(2 * 60 * 1000) | |
} | |
} | |
} | |
} | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment