Commit 3948c230 by Karsa Zoltán István

Add globals

parent d127ae60
...@@ -4,10 +4,15 @@ import json ...@@ -4,10 +4,15 @@ import json
import os import os
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from urllib.parse import urljoin from urllib.parse import urljoin
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
ssl._create_default_https_context = ssl._create_unverified_context
# az adott ZH eredményeire mutató összefoglaló link # az adott ZH eredményeire mutató összefoglaló link
ILIAS_URL = 'https://edu.vik.bme.hu/mod/quiz/report.php?id=124407&mode=overview' ILIAS_URL = 'https://edu.vik.bme.hu/mod/quiz/report.php?id=124391&mode=overview'
ssl._create_default_https_context = ssl._create_unverified_context TARGET_COL = 'cell c14'
FILE_PATH = 'kisZH2_pent_c14.json'
def shibboleth_auth(session, url, credentials): def shibboleth_auth(session, url, credentials):
print("Shibboleth Auth…") print("Shibboleth Auth…")
...@@ -79,12 +84,14 @@ def main(): ...@@ -79,12 +84,14 @@ def main():
responses = soup.find_all("td", class_="cell c4") # neptun oszlopának class azonja responses = soup.find_all("td", class_="cell c4") # neptun oszlopának class azonja
neptuns = [a.get_text() for a in responses if len(a.get_text()) == 6] neptuns = [a.get_text() for a in responses if len(a.get_text()) == 6]
responses = soup.find_all("td", class_="cell c27", limit=len(neptuns)) # az adott részkérdés (CodeRunner) oszlopának class azonja responses = soup.find_all("td", class_=TARGET_COL, limit=len(neptuns)) # az adott részkérdés (CodeRunner) oszlopának class azonja
hrefs = [a.find("a" , recursive=False)["href"] for a in responses] hrefs = [a.find("a" , recursive=False)["href"] for a in responses]
# CodeRunner típusú response history-k mentésére (különben csak az utolsó válasz tölthető le) # CodeRunner típusú response history-k mentésére (különben csak az utolsó válasz tölthető le)
todict = { } todict = { }
print("Collect results")
for i in range(0, len(neptuns)): for i in range(0, len(neptuns)):
neptun = neptuns[i] neptun = neptuns[i]
...@@ -114,8 +121,11 @@ def main(): ...@@ -114,8 +121,11 @@ def main():
"states": states, "states": states,
"marks": marks "marks": marks
} }
if (i % 10 == 0):
print(f"{(i * 100.0 / float(len(neptuns)))} %")
with open("ZH2Ac27.json", 'w', encoding ='utf8') as json_file: print("Save json...")
with open(FILE_PATH, 'w', encoding ='utf8') as json_file:
json.dump(todict, json_file) json.dump(todict, json_file)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment