This repository contains a template for recording LeetCode problems and a notebook that automates the process of inserting an entry into a Notion table based on a LeetCode link. The notebook extracts information such as problem title, number, link, difficulty, and problem description from the LeetCode website and inserts it into the specified Notion table.
The template I have created and use is available here. Feel free to use it. If you prefer to use your own table, make sure the column names (Problem, Name, Link, Difficulty) are consistent with mine for the integration. If not, you may need to modify the script accordingly.
If you are using Google Colab (which I recommend), there are no prerequisites other than opening this Google Colab notebook, making a copy, and skipping to the "Setup" section.
If you prefer to run the notebook in Jupyter Notebook/VS code, make sure you have the following prerequisites installed:
- Python 3.6 or above
- Required Python libraries: requests, beautifulsoup4, pandas, notion (You can install them by running
pip3 install -r requirements.txt
)
-
Follow the tutorial from the official Notion API documentation from step 1 to step 3.
-
Make a copy of your Notion integration token and database ID of your table (copy the link of the table or just open it in the browser to view the link).
-
Open the
leetcode_to_notion.ipynb
notebook using Jupyter Notebook. -
In the notebook, provide your Notion API token and database URL.
-
Run All, and make sure to provide the LeetCode link when prompted.
-
The notebook will extract the necessary information from the LeetCode page and insert it into the specified Notion table.
Please let me know if you have any further questions or need additional assistance.