Skip to content

Instantly share code, notes, and snippets.

@nettofarah
Created May 4, 2021 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nettofarah/2f8a3ae4a5fa3b4ba26ac7f00295b11b to your computer and use it in GitHub Desktop.
Save nettofarah/2f8a3ae4a5fa3b4ba26ac7f00295b11b to your computer and use it in GitHub Desktop.
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()
@nettofarah
Copy link
Author

nettofarah commented May 21, 2021

Instructions:

  • Change the URL to match your zipcode and model
  • Run the following commands
npm init
npm install --save puppeteer say
node tesla-finder.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment