Skip to content

Commit f55ff75

Browse files
committed
Fix issue for finding url of ac submission
1 parent 828a46f commit f55ff75

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

LeetCode_AC_Code_Crawler.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ def save_ac_code(ac_list, premium):
3232
print("Do you want to over write all files if they exists? yes/no")
3333
overWrite = raw_input()
3434

35+
level = ["None", "Easy", "Medium", "Hard"]
36+
3537
start_time = time.time()
3638

3739
for ac in reversed(ac_list):
@@ -43,19 +45,17 @@ def save_ac_code(ac_list, premium):
4345
continue
4446

4547
url = ac["url"]
46-
driver.get(url)
47-
48-
level = ["None", "Easy", "Medium", "Hard"]
4948
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 = ""
5350

5451
while len(ac_submission) == 0:
52+
driver.get(url)
53+
time.sleep(1)
5554
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]
5757

58-
driver.get("https://leetcode.com" + ac_submission[0].parent["href"])
58+
driver.get("https://leetcode.com" + ac_submission[0]["href"])
5959
soup = BeautifulSoup(driver.page_source, "html.parser")
6060

6161
#get submission details
@@ -177,7 +177,7 @@ def suffix_conversion(suff="cpp"):
177177
return suffix[suff]
178178

179179
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:
181181
conf = json.loads(f.read())
182182
username = conf["Username"]
183183
password = conf["Password"]

0 commit comments

Comments
 (0)