Selenium driver is used to fetch the urls of top voted answers for each question. urls.txt
is generated. answers.py
parses this file and write answers into a MongoDB collection. You can use urls.txt
to do your own thing. Its format is:
question_num:number_of_answer_count_follows_this_line
answer_url
answer_url
...
number_of_answer_count_follows_this_line
is usually 10
Selenium driver is used to get urls.txt
because the discussion forum does not order the answers by votes by default. To do that you need to log in and choose that option. Since that option will be remembered by the server, it's not necessary to use the driver anymore. requests
can be used instead.
All answers in the document are attributed to their authors. If you see your answers in there and would rather your answer not be included, send me a note at [email protected].
Also be responsible if you use this script to crawl leetcode. Use time.sleep
.
There is an app too! Leetcoder.
Check out GeeksforGeeks Reader as well!
Just open an issue.