Skip to content

Instantly share code, notes, and snippets.

@Dharisd
Created December 28, 2019 18:44
Show Gist options
  • Save Dharisd/138feb2931460ed2bbbcd0e6d2fed2b0 to your computer and use it in GitHub Desktop.
Save Dharisd/138feb2931460ed2bbbcd0e6d2fed2b0 to your computer and use it in GitHub Desktop.

Automating the boring stuff: past papers

While i was studying for a levels. i found out i was spending a lot of time searching for and downloading past papers.since the sites that offered these files were clumsy had not so great ux.finding a single past past paper required you to naviagte to atleast three pages.The final page being an index of all past papers for that particular subject. so like any sane person i went on and created pastpaper bot aka ppbot.

insert image of ppbot

how it works?

i found out that the pastpaper sites are like huge indexes containing files which are named to a standard convenient format. i used this to my advantage an wrote a quick scraper.the final scraper takes works like this

bash scrp.py -url physicsmrathstutor.com/

the scraper identifies the subject and unit of the past paper.and stores all entries on the url to a mongodb.another script then downloads these pdfs and makes them available locally

The telegram bot

making the telegram bot was quite straight forward i just had to get enough data from the user and call the db to get the files. i used the python telegram bot package to easily interact with python

insert image of source

The bot

i didnt expect much if any users to actually use it other than me. but by the time the exams ended the bot had more than 2000 pastpapers to x unique students.

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