Skip to content

SaraSaadoun/Leetcode-Scraper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🚀 LeetCode Scraper

Automate the process of saving your LeetCode solutions with ease! This scraper authenticates, extracts solutions, saves metadata, and commits automatically using Git.

🔹 Features

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! 🔄

📂 Project Structure

│── 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

🛠️ Installation

git clone https://github.com/SaraSaadoun/Leetcode-Scraper.git  
cd Leetcode-Scraper  
pip install -r requirements.txt

🔹 Setup .env File

Before 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

🚀 Running the Scraper

cd src
python auth.py
python main.py --slug problem-slug-here

🔹 Usage Notes

  • The --slug argument 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_submissions flag:
python main.py --slug problem-slug-here --all_submissions

🖥️ Running with UI

For a simpler experience, you can run the scraper with a graphical user interface:

python main_ui.py

This will allow you to input the problem name/slug and choose options interactively.

About

Scraper for automating the extraction of LeetCode problem descriptions and solutions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages