Created
May 4, 2021 21:53
This file contains hidden or 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 say = require('say') | |
async function find(page) { | |
await page.goto( | |
'https://www.tesla.com/inventory/new/my?arrangeby=relevance&zip=78724&range=200', | |
{ | |
waitUntil: 'networkidle2', | |
} | |
) | |
await page.waitForSelector('.result', { | |
timeout: 10000, | |
}) | |
const results = await page.$$('.result') | |
const cars = await Promise.all( | |
results.map((res) => { | |
return res.$eval('.result-basic-info', (el) => el.textContent) | |
}) | |
) | |
cars.forEach((car) => { | |
say.speak(car) | |
}) | |
} | |
async function main() { | |
const browser = await puppeteer.launch({ | |
headless: false, | |
}) | |
const page = await browser.newPage() | |
await find(page) | |
setInterval( | |
() => find(page), | |
// 10 minutes | |
600000 | |
) | |
} | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instructions: