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.