paint-brush
Scrapping your Hackerrank.com submissions with pythonby@hearsid
1,144 reads
1,144 reads

Scrapping your Hackerrank.com submissions with python

by Siddharth SharmaJanuary 13th, 2019
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

There are many repositories on <a href="http://github.com" target="_blank">github</a> where people upload their solutions to the problems they have solved on <a href="http://hackerrank.com" target="_blank">hackerrank</a>. When I started solving problems on <a href="https://hackernoon.com/tagged/hackerrank" target="_blank">hackerrank</a>, I also started doing the same since it provides as a place to go through the things I had practiced. But as I started solving more problems, it became difficult to manually copy paste them so I wrote a <a href="https://hackernoon.com/tagged/python" target="_blank">python</a> script that can do the same.
featured image - Scrapping your Hackerrank.com submissions with python
Siddharth Sharma HackerNoon profile picture

There are many repositories on github where people upload their solutions to the problems they have solved on hackerrank. When I started solving problems on hackerrank, I also started doing the same since it provides as a place to go through the things I had practiced. But as I started solving more problems, it became difficult to manually copy paste them so I wrote a python script that can do the same.

Currently the script is configured to scrap though the Java and python tracks, and can be configured to add additional tracks by adding them in tracks array. For the source code here is the repository link, first link is of the scrapper and second of my hackerrank solutions for reference.https://github.com/hearsid/hackerrank-scrapper

https://github.com/hearsid/hackerrank-scr

https://github.com/hearsid/hackerrank-scrapper


hearsid/hackerrank_Hackerrank submitted solutions scraper and my submitted solutions. - hearsid/hackerrank_github.com

Here are the steps to use it for your account

  1. Clone the above repository, or you can copy the required python files.
  2. Login to your hackerrank account and copy the CSRF token and cookie from the headers of any of XHR request. (You can check the same in the network tab of chrome devtools)
  3. Create a credentials.py file in the same folder and add your CSRF token and cookie in the same. Sample given after 6th point.
  4. Go to scraper.py file and add the tracks you want to scrap in the TRACKS array.
  5. Go to util.py file and for the tracks update the extension with which you would like to save the file.
  6. Run > python scraper.py



# credentials.pyCSRF_TOKEN = ‘CVKP-XXXX-lYT7iQ==’COOKIE = ‘hackerrank=ea729eb0–XXXX-3114’

The hackerrank URL’s I have used in the above repository work well now but may change over time. Please create an issue if you find anything not working or would like to request a feature.