Skip to content

Instantly share code, notes, and snippets.

@arunkp
Last active April 5, 2022 11:55
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 arunkp/7925eb89848257f7be647e0945c8f45c to your computer and use it in GitHub Desktop.
Save arunkp/7925eb89848257f7be647e0945c8f45c to your computer and use it in GitHub Desktop.
appointments
// 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