Automate the process of saving your LeetCode solutions with ease! This scraper authenticates, extracts solutions, saves metadata, and commits automatically using Git.
β
Authenticates on LeetCode
β
Scrapes code, language, runtime, memory, and problem description
β
Adjusts file extensions based on the detected programming language
β
Saves metadata (runtime & memory) in a JSON file
β
Stores problem descriptions in a Markdown file
β
Organizes everything in a directory named after the problem slug
β
Commits automatically using Git after scraping π―
β
Choose what to scrape β Select all submissions or just the latest one! π
βββ LeetCodeSolutions/
βββ src/ β
βββ controllers/
β β βββ file_controller.py
β β βββ git_controller.py
β βββ scrapers/
β β βββ scraper.py
β βββ utils/
β β βββ config.py
β βββ auth.py
β βββ main_ui.py
β βββ main.py
βββ .gitignore
βββ README.md
βββ requirements.txt
git clone https://github.com/SaraSaadoun/Leetcode-Scraper.git
cd Leetcode-Scraper
pip install -r requirements.txtBefore running the script, create a .env file in the project directory and define the absolute path where you want to save the scraped solutions:
LEETCODE_SOLUTIONS_DIR_PATH=/absolute/path/to/save/solutions
cd src
python auth.py
python main.py --slug problem-slug-here- The
--slugargument accepts both problem slugs (e.g.,two-sum) and problem names (e.g.,"Two Sum"). - If you want to scrape all accepted solutions instead of just the latest one, pass the
--all_submissionsflag:
python main.py --slug problem-slug-here --all_submissionsFor a simpler experience, you can run the scraper with a graphical user interface:
python main_ui.pyThis will allow you to input the problem name/slug and choose options interactively.