from getpass import getpass
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
username = "ioangeor14"
password = getpass("Enter yoyr Password")
url_login = "https://egram.cm.ihu.gr/unistudent/"
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches",["enable-logging", "enable-automation"])
driver = webdriver.Chrome(options=options, executable_path=r"C:\\Temp\\chromedriver")
driver.get(url_login)
driver.find_element_by_name("userName1").send_keys(username)
driver.find_element_by_name("pwd").send_keys(password)
driver.find_element_by_name("submit1").click()
driver.get("https://egram.cm.ihu.gr/unistudent/studentMain.asp")
url_vathmoi = "https://egram.cm.ihu.gr/unistudent/stud_CResults.asp?studPg=1&mnuid=mnu3&"
driver.get(url_vathmoi)
before_XPath = "//*[@id='mainTable']/tbody/tr[2]/td/table/tbody/tr[50"
aftertd_XPath = "]/td["
aftertr_XPath = "]"
#before_XPath = "//*[@id='mainTable']/tbody/tr["
#aftertd_XPath = "]/td["
#aftertr_XPath = "]"
rows = len(driver.find_elements_by_xpath("//*[@id='mainTable']/tbody/tr"))
print(rows)
columns = len(driver.find_elements_by_xpath("//*[@id='mainTable']/tbody/tr[2]/td"))
print(columns)
for t_row in range(2, (rows + 1)):
for t_column in range(1, (columns + 1)):
FinalXPath = before_XPath + aftertd_XPath + str(t_column) + aftertr_XPath
cell_text = driver.find_element_by_xpath(FinalXPath).text
with open("VATHMOI.txt", "w", encoding="utf-8") as f:
f.write(cell_text)
driver.close()
#driver.quit()
#while (driver.find_element(By.XPATH, "/html/body/table/tbody/tr[4]/td[2]/table/tbody/tr/td[1]/span[1]")):
# time.sleep(5)
# driver.get(url_vathmoi)
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}