A Python script to simplify LeetCode problem-solving by generating a Jupyter Notebook template from problem URLs.
This uses selenium to scrape from LeetCode. Since there's no LeetCode API that we could use, and headless requests don't give us the whole site, we have to launch a browser instance using selenium and get the information about the problem through that browser.
- Clone the repository:
git clone https://github.com/ixora-0/leetcode-notebook-generator.git cd leetcode-notebook-generator
- Install dependencies
Using poetry
poetry install
pip install -r requirements.txt
Using poetry
poetry run generate <url> -d <path>
Without poetry
python -m leetcode_notebook_generator <url> -d <path>
Replace <url>
with the URL of the LeetCode problem you want to generate a Jupyter Notebook for. Replace <path>
with th edestination folder, default is ./output/
.
poetry run generate https://leetcode.com/problems/two-sum/ -d ./sample_output/
or
python -m leetcode_notebook_generator https://leetcode.com/problems/two-sum/ -d ./sample_output/
This will generate a Jupyter Notebook with a template for the Two Sum problem.
This project is licensed under the GNU General Public License v3.0 (GPL-3.0). See the LICENSE file for details.