Last active
April 5, 2022 11:55
appointments
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
// Make sure you have node installed on your machine. If not install using NVM: https://github.com/nvm-sh/nvm#installing-and-updating | |
// Install these dependencies https://www.npmjs.com/package/puppeteer and https://www.npmjs.com/package/node-schedule | |
// just run node appointment.js | |
// Increase your system volume so that you hear continuous beeps or alerts. | |
// Its easy to stop the script: just do "Control + C" and it will stop the script | |
// Post your comments below if you find any updates on this code. | |
const puppeteer = require("puppeteer"); | |
const schedule = require("node-schedule"); | |
const os = require('os'); | |
const rule = new schedule.RecurrenceRule(); | |
rule.minute = new schedule.Range(0, 59, 1); | |
const delay = (time) => { | |
return new Promise(function (resolve) { | |
setTimeout(resolve, time) | |
}); | |
} | |
const findAppointments = async () => { | |
const browser = await puppeteer.launch({ headless: true }); | |
const page = await browser.newPage(); | |
await page.goto('https://terminvereinbarung.muenchen.de/fs/termin/index.php?loc=FS&ct=1071898'); | |
const form = await page.$('input.WEB_APPOINT_FORWARDBUTTON'); | |
await form.evaluate(form => form.click()); | |
await delay(2000); | |
const table = await page.$(".location_list"); | |
const availability = await table.$(".nat_calendar_weekday_bookable"); | |
if (availability) { | |
await page.screenshot({ path: 'availability.png' }); | |
console.log("Found new appointments: https://terminvereinbarung.muenchen.de/fs/termin/index.php?loc=FS&ct=1071898"); | |
setInterval(() => { | |
if (os.platform() === "win32") { | |
require("child_process").exec("powershell.exe [console]::beep(500,600)") | |
} | |
if (os.platform() === "darwin") { | |
require("child_process").exec("afplay /System/Library/Sounds/Glass.aiff") | |
} | |
}, 1000) | |
} | |
await browser.close() | |
} | |
schedule.scheduleJob(rule, function () { | |
findAppointments(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment