中文版 | English
When practicing on LeetCode, you often encounter problems similar to ones you've solved before, but forget the solution approach. Anki is a cross-platform memory tool based on the forgetting curve, supporting Mac, Linux, Windows, iOS, and Android platforms. While Anki is an excellent memory tool, it requires manual card creation, which is tedious and time-consuming.
Invest some time to automate or simplify a process to save more time in the future
This project aims to automatically fetch your accepted LeetCode problems and generate Anki decks to help you remember them.
The crawled data includes:
- Problem title, difficulty, and description.
- Official solutions (Premium solutions require a subscription to fetch).
- Your accepted submission code.
| Front | Back |
|---|---|
Example Deck
First, clone the repository and install Python dependencies:
git clone https://github.com/tabloomoo/LeetCode-Anki.git
cd LeetCode-Anki
pip3 install -r requirements.txtRun the crawler and output the Anki deck to ./data/LeetCode.apkg (as specified in project.conf):
python3 main.pyFor LeetCode.cn support:
python3 main_cn.pyOn the first run, you need to obtain cookies. Running main.py will open a Chrome window where you manually enter your username and password to log in once.
⚠️ Note:
- If you need to re-login via browser, simply delete the
cookie.datfile in the directory.- If the browser driver is outdated (currently V86.0), please download the Chrome Selenium driver and replace the old driver in the
vendordirectory.
Enjoy using Anki to review the problems you've solved!
If you don't like the default Anki card style, you can modify the following three parameters in project.conf to customize the generated Anki cards:
[DB]
path = ./data
debug = False
[Anki]
front = ./templates/front-side.html
back = ./templates/back-side.html
css = ./templates/style.css
output = ./data/LeetCode.apkgfront: The format of the card front side.back: The format of the card back side.css: The CSS style for the cards.
This project is licensed under the GPL V3 open source license.
This project is based on many excellent open source projects: