@@ -59,11 +59,14 @@ def get_config_from_file():
59
59
if not repo :
60
60
raise Exception ('Please input your Github repo address' )
61
61
62
+ driverpath = cp .get ('leetcode' , 'driverpath' )
63
+
62
64
rst = dict (
63
65
username = username ,
64
66
password = password ,
65
67
language = language .lower (),
66
68
repo = repo ,
69
+ driverpath = driverpath ,
67
70
)
68
71
return rst
69
72
@@ -193,9 +196,9 @@ def login(self):
193
196
pwd = CONFIG ['password' ]
194
197
# driver = webdriver.PhantomJS()
195
198
options = webdriver .ChromeOptions ()
196
- # options.add_argument('headless')
199
+ options .add_argument ('headless' )
197
200
options .add_argument ('--disable-gpu' )
198
- executable_path = '/usr/local/bin/chromedriver'
201
+ executable_path = CONFIG . get ( 'driverpath' )
199
202
driver = webdriver .Chrome (
200
203
chrome_options = options , executable_path = executable_path
201
204
)
@@ -473,14 +476,13 @@ def download(self):
473
476
""" download all solutions with single thread """
474
477
ac_items = [i for i in self .items if i .is_pass ]
475
478
for quiz in ac_items :
479
+ time .sleep (1 )
476
480
self ._download_code_by_quiz (quiz )
477
481
478
482
def download_with_thread_pool (self ):
479
483
""" download all solutions with multi thread """
480
484
ac_items = [i for i in self .items if i .is_pass ]
481
-
482
485
from concurrent .futures import ThreadPoolExecutor
483
-
484
486
pool = ThreadPoolExecutor (max_workers = 4 )
485
487
for quiz in ac_items :
486
488
pool .submit (self ._download_code_by_quiz , quiz )
0 commit comments