Fork form https://github.com/bonfy/leetcode
Use selenium and PhantomJS
I think it's not the best way. But I can't find way leetcode encrypt the csrftoken. If anyone find the encrypt algoristhm, please pull request to me. And I can change the login to requests
Install PhantomJS please follow PhantomJS official website
Mac Users can install PhantomJS by Homebrew
$ brew install phantomjsInstall essential packages: requests, pyquery,selenium
$ pyvenv venv # create virtual environment
$ source venv/bin/activate
$ pip3 install -r req.txtEdit your own username, password, language and repo in the config.cfg file
[leetcode]
username = username
password = password
language = python
repo = https://github.com/bonfy/leetcode
python3 leetcode_generate.pyUsually you can always run fully download
python3 leetcode_generate.py 1
python3 leetcode_generate.py 1 10 100
You can only download the solution you want. Just add the id arguments behind (seperate by space)
Python 3 have tested
Python 2 maybe
- 2016-10-09 Download codes from Leetcode and generate Readme
- 2016-11-25 Add multi language support
- 2017-01-02 Fix the bug cause by Leetcode change website:
PHPSESSIDchange toLEETCODE_SESSION - 2017-04-22 Fix the bug cause by Leetcode change website: csrftoken encrypt, submissions change from HTML to JSON

