-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem.py
More file actions
64 lines (61 loc) · 2.68 KB
/
problem.py
File metadata and controls
64 lines (61 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# By Amit Kumar
# drviruses (@github)
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from os import path
from selenium import webdriver
from selenium.webdriver.support.ui import Select
import pickle
import datetime
import csv
import hyperlink
from time import sleep
totPages = 1 #upto this page
Ac = "Accepted"
arr = [ "Pupil" ,"Specialist" ,"Expert" , "Candidate Master" , "International Master"]
if __name__ == "__main__":
driver = webdriver.Chrome(executable_path="./chromedriver")
try:
userId = input("Enter the UserName : ")
clrId = int(input("Enter the color Id : \n 1. Pupil \n 2. Specialist \n 3. Expert \n 4. Candidate Master \n 5. International Master \n "))
color = arr[clrId-1]
driver.get("https://codeforces.com/submissions/" + userId)
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CLASS_NAME, "status-frame-datatable"))
)
cur = 3 #maxpages
with open('ProblemList.csv', 'w', newline = '\n') as f:
thewriter = csv.writer(f)
while(cur >= totPages):
driver.get("https://codeforces.com/submissions/" + userId + "/page/" + str(cur))
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CLASS_NAME, "status-frame-datatable"))
)
table = driver.find_element_by_css_selector('table.status-frame-datatable')
for row in table.find_elements_by_css_selector("tr"):
isAc = False
isCol = False
linkP = ""
nameP = ""
itr = 0
for cell in row.find_elements_by_tag_name("td"):
if itr == 5:
theAc = cell.find_element_by_tag_name("span")
if Ac == theAc.text:
isAc = True
if itr == 2:
hr = cell.find_element_by_tag_name("a")
if hr.get_attribute("title") == color + " " + userId:
isCol = True
if itr == 3:
nameP = cell.text
ll = cell.find_element_by_tag_name("a")
linkP = ll.get_attribute("href")
itr = itr + 1
if isAc and isCol:
thewriter.writerow([nameP, linkP])
print(linkP)
cur = cur - 1
finally:
driver.quit()