Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Prog2
/
stat
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3948c230
authored
a year ago
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add globals
parent
d127ae60
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
moodle_scraping.py
+14
-4
No files found.
moodle_scraping.py
View file @
3948c230
...
...
@@ -4,10 +4,15 @@ import json
import
os
from
bs4
import
BeautifulSoup
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
ILIAS_URL
=
'https://edu.vik.bme.hu/mod/quiz/report.php?id=124407&mode=overview'
ssl
.
_create_default_https_context
=
ssl
.
_create_unverified_context
ILIAS_URL
=
'https://edu.vik.bme.hu/mod/quiz/report.php?id=124391&mode=overview'
TARGET_COL
=
'cell c14'
FILE_PATH
=
'kisZH2_pent_c14.json'
def
shibboleth_auth
(
session
,
url
,
credentials
):
print
(
"Shibboleth Auth…"
)
...
...
@@ -79,12 +84,14 @@ def main():
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
]
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
]
# CodeRunner típusú response history-k mentésére (különben csak az utolsó válasz tölthető le)
todict
=
{
}
print
(
"Collect results"
)
for
i
in
range
(
0
,
len
(
neptuns
)):
neptun
=
neptuns
[
i
]
...
...
@@ -114,8 +121,11 @@ def main():
"states"
:
states
,
"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
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment