-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest1.py
69 lines (50 loc) · 2.34 KB
/
test1.py
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
65
66
67
68
69
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import JavascriptException
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wdw
from selenium.webdriver.support import expected_conditions as EC
import pandas as pd
from bs4 import BeautifulSoup
from tabulate import tabulate
from os import getcwd
from datetime import date
today = date.today().strftime("%d-%m-%Y")
#Disabling console logging
opt = Options()
opt.add_experimental_option("excludeSwitches", ["enable-logging"])
#Stopping images from Loading
prefs = {"profile.managed_default_content_settings.images": 2}
opt.add_experimental_option("prefs", prefs)
#Avoiding "Your Connection is not private" error
opt.add_argument('--ignore-ssl-errors=yes')
opt.add_argument('--ignore-certificate-errors')
#Performance boost
opt.add_argument('--no-proxy-server')
opt.add_argument("--proxy-server='direct://'")
opt.add_argument("--proxy-bypass-list=*")
#opt.add_argument('--headless')
path = getcwd() + '/chromedriver.exe'
driver = webdriver.Chrome(options = opt, executable_path = path)
driver.get('https://info.aec.edu.in/aec/default.aspx')
driver.find_element_by_id('txtId2').send_keys('---UID---')
driver.find_element_by_id('txtPwd2').send_keys('---PWD---')
log_in = driver.find_element_by_id('imgBtn2')
driver.execute_script("arguments[0].click();", log_in)
driver.find_elements_by_class_name('menuLink')[0].click()
driver.switch_to.frame('capIframeId')
driver.find_element_by_id('radPeriod').click()
driver.find_element_by_id('txtFromDate').send_keys(today)
driver.find_element_by_id('txtToDate').send_keys(today)
driver.find_element_by_id('btnShow').click()
wdw(driver,20).until(EC.presence_of_element_located((By.CLASS_NAME,"cellBorder")))
soup = BeautifulSoup(driver.page_source, 'html.parser')
tables = soup.find_all('table', class_='cellBorder')
dfs = pd.read_html(str(tables))
dfs[0].drop([0], axis = 0, inplace = True)
headers = ["Sl.No","Subject","Held","Attend","%"]
print(tabulate(dfs[0], headers, tablefmt='pretty', showindex=False))
driver.switch_to.default_content()
driver.find_element_by_id('lnkLogOut').click()
driver.quit() #Used to close the driver