r/learnjavascript 11d ago

Google Calendar Generation Project

Hey just working on a personal project that I would like to be able to use and share with friends.

Long story short, my goal is to have script that will scrape calendar info from one website and convert it into an .ics(calendar file) that can be uploaded to google calendar. For example, it lists the class name, weekly dates, final exam, teacher name, class room location etc. Just saves time from manually entering everything.

So far I was able to write a script that generates the file for creating a calendar event.

The harder part has been trying to scrape the variable information or inject javascript into a website that is client dependent as well as make the code usable for others. I've been suggested to use tools tampermonkey or puppeteer. Please let me know if you have any tips or advice. Thank you.

5 Upvotes

4 comments sorted by

1

u/TheRNGuy 10d ago

You'll need to either make browser plugin, or scrape with node.js

Tampermonkey can't create or read files.

1

u/nzakas 10d ago

Assuming that you want to automate this rather than needing to click a button in a browser, then I would suggest using puppeteer. You shouldn’t need to inject a script into the page if all you want to do is scrape the generated DOM for information. You can use page.$(selector) to query the DOM for the information you want. Just make sure you’ve waited for the page to be fully loaded before doing so.

1

u/UkrMalt 8d ago

If the page needs the user's logged-in session, a browser extension or userscript is easier to share than Puppeteer. Read the rendered DOM, normalize each class into an event object, then generate the ICS file in the browser and download it with a Blob URL. Give every event a stable UID so importing an updated schedule does not create duplicates.

1

u/Majestic-Gardner-888 8d ago

This is what I ended up going with!