Created
May 4, 2021 21:53
-
-
Save nettofarah/2f8a3ae4a5fa3b4ba26ac7f00295b11b 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 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: