Skip to content

Commit 7009f68

Browse files
author
Bishal Sarangkoti
authored
Update README.md
1 parent bd63700 commit 7009f68

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
Leetcode Questions Scrapper is a simple scrapper built on top of Selenium that fetches all the problems from leetcode and write as html and epub files.
44

5+
Although leetcode doesn't provide an official API to fetch all the list of problems, we can use the API url [https://leetcode.com/api/problems/algorithms/](https://leetcode.com/api/problems/algorithms/) used by leetcode internally to fetch problems that returns a json file containing info about problems.
6+
The json file looks like this <br>
7+
![enter image description here](https://qph.fs.quoracdn.net/main-qimg-4ddf7b592d1a47df4385ffc714c215b7)<br>
8+
We can build links to each problem as
9+
10+
“https://leetcode.com/problems/" + question_title_slug
11+
After getting the problem link we can fetch the content from the page using selenium (as Leetcode is built using react where content is rendered using JS we can't use lightweight library like requests).
12+
513
You can download the sample html and epub containing 11 problems [here](https://github.com/sarangbishal/Leetcode-Questions-Scrapper/tree/master/assets/sample%20output%20files).
614

715
## Requirements
@@ -23,7 +31,7 @@ Pip install all the requirements.
2331
- Run the following commands to download all algorithmic problems from leetcode
2432
`python main.py`
2533
![enter image description here](https://raw.githubusercontent.com/sarangbishal/Leetcode-Questions-Scrapper/master/assets/screenshots/main.PNG?token=AG2ULFBE5HCEDG2FYTXPFW25RNWCU)
26-
<br>This downloads problem contents to 2 files: *****out.html***** and ***chapters.pickle***.
34+
This downloads problem contents to 2 files: *****out.html***** and ***chapters.pickle***.
2735

2836
**NOTE:** Leetcode may temporarily block requests. If the error occurs, wait for sometime and try again or use the proxy. Don't worry, Since, the previous state is saved to ***track.conf*** file, the download resumes from where it failed.
2937

0 commit comments

Comments
 (0)