@@ -32,6 +32,8 @@ def save_ac_code(ac_list, premium):
32
32
print ("Do you want to over write all files if they exists? yes/no" )
33
33
overWrite = raw_input ()
34
34
35
+ level = ["None" , "Easy" , "Medium" , "Hard" ]
36
+
35
37
start_time = time .time ()
36
38
37
39
for ac in reversed (ac_list ):
@@ -43,19 +45,17 @@ def save_ac_code(ac_list, premium):
43
45
continue
44
46
45
47
url = ac ["url" ]
46
- driver .get (url )
47
-
48
- level = ["None" , "Easy" , "Medium" , "Hard" ]
49
48
difficulty = level [ac ["difficulty" ]]
50
-
51
- soup = BeautifulSoup (driver .page_source , "html.parser" )
52
- ac_submission = soup .find_all ("strong" , text = "Accepted" )
49
+ ac_submission = ""
53
50
54
51
while len (ac_submission ) == 0 :
52
+ driver .get (url )
53
+ time .sleep (1 )
55
54
soup = BeautifulSoup (driver .page_source , "html.parser" )
56
- ac_submission = soup .find_all ("strong" , text = "Accepted" )
55
+ ac_submission = soup .find_all ("a" , text = "Accepted" )
56
+ print ac_submission [0 ]
57
57
58
- driver .get ("https://leetcode.com" + ac_submission [0 ]. parent ["href" ])
58
+ driver .get ("https://leetcode.com" + ac_submission [0 ]["href" ])
59
59
soup = BeautifulSoup (driver .page_source , "html.parser" )
60
60
61
61
#get submission details
@@ -177,7 +177,7 @@ def suffix_conversion(suff="cpp"):
177
177
return suffix [suff ]
178
178
179
179
if __name__ == "__main__" :
180
- with open ('C:\Users\jj251\Desktop\LeetCode-AC-Code-Crawler\ conf.json' , 'r' ) as f :
180
+ with open ('conf.json' , 'r' ) as f :
181
181
conf = json .loads (f .read ())
182
182
username = conf ["Username" ]
183
183
password = conf ["Password" ]
0 commit comments