-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathscript.py
More file actions
30 lines (21 loc) · 685 Bytes
/
script.py
File metadata and controls
30 lines (21 loc) · 685 Bytes
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
import requests, bs4
import os,subprocess
import sqlite3,schedule,time
cursor = sqlite3.connect('ranklist.db',check_same_thread=False)
def work():
response = requests.get('http://iitiranklist.herokuapp.com/?')
souped = bs4.BeautifulSoup(response.text)
handle_elements = souped.select('#handle')
handles = []
for element in handle_elements:
handles.append(element.getText())
for handle in handles:
qry = '''insert into handles values('%s',0)''' %(handle)
try:
cursor.execute(qry)
except:
print("%s already exists"%(handle))
cursor.commit()
print(handles)
print(len(handles))
work()