Skip to content

Commit c61c680

Browse files
committed
Initial Commit
0 parents  commit c61c680

20 files changed

+22677
-0
lines changed

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# dependencies
2+
/node_modules
3+
/.pnp
4+
.pnp.js
5+
6+
# testing
7+
/coverage
8+
9+
# production
10+
/build
11+
12+
# misc
13+
.DS_Store
14+
.env.local
15+
.env.development.local
16+
.env.test.local
17+
.env.production.local
18+
19+
npm-debug.log*
20+
yarn-debug.log*
21+
yarn-error.log*
22+
23+
problems/
24+
solutions/

README.md

Whitespace-only changes.

dump_solutions.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os
2+
import json
3+
4+
problem_dict = {}
5+
problem_files = os.listdir('./problems')
6+
7+
for file in problem_files:
8+
9+
filename = file.split('.')[0]
10+
11+
with open('./problems/'+file, 'r') as json_file:
12+
problem_dict[filename] = json.loads(json_file.read())
13+
problem_dict[filename]['number'] = filename
14+
15+
with open('./src/solutions.json', 'w') as json_file:
16+
json.dump(problem_dict, json_file)

link_scraper.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import time
2+
import json
3+
4+
from selenium import webdriver
5+
from selenium.webdriver.common.keys import Keys
6+
7+
driver = webdriver.Chrome()
8+
driver.get('https://leetcode.com/problemset/algorithms/')
9+
10+
input("Change filter to show all problems: ")
11+
12+
links = {}
13+
14+
count = 1
15+
16+
while True:
17+
try:
18+
19+
link_ele = driver.find_element_by_xpath('//*[@id="question-app"]/div/div[2]/div[2]/div[2]/table/tbody[1]/tr['+str(count)+']/td[3]/div/a')
20+
link = link_ele.get_attribute('href')
21+
name = link_ele.get_attribute('innerHTML')
22+
23+
difficulty_ele = driver.find_element_by_xpath('//*[@id="question-app"]/div/div[2]/div[2]/div[2]/table/tbody[1]/tr['+str(count)+']/td[6]/span')
24+
difficulty = difficulty_ele.get_attribute('innerHTML')
25+
26+
number_ele = driver.find_element_by_xpath('//*[@id="question-app"]/div/div[2]/div[2]/div[2]/table/tbody[1]/tr['+str(count)+']/td[2]')
27+
number = number_ele.get_attribute('innerHTML')
28+
29+
links[number] = {
30+
'link': link,
31+
'name': name,
32+
'difficulty': difficulty
33+
}
34+
35+
count += 1
36+
if count % 50 == 0:
37+
print(count)
38+
39+
except:
40+
break
41+
42+
with open('links.json', 'w') as json_file:
43+
json.dump(links, json_file)

0 commit comments

Comments
 (0)