mirror of
https://github.com/KevinMidboe/ITLscraper.git
synced 2025-10-29 17:50:14 +00:00
gui fix and folder selection
This commit is contained in:
24
app.py
24
app.py
@@ -1,5 +1,7 @@
|
||||
import appJar
|
||||
import itl_scrape
|
||||
import os
|
||||
|
||||
from appJar import gui
|
||||
from itl_scrape import itslearning_scraper
|
||||
|
||||
@@ -30,6 +32,12 @@ def select_all(btn):
|
||||
app.setCheckBox(courses[label], ticked=True, callFunction=False)
|
||||
print("select all")
|
||||
|
||||
def select_folder(btn):
|
||||
path = app.directoryBox(title="Folder to save into", dirName=None)
|
||||
print(path)
|
||||
app.setLabel("path", path)
|
||||
scraper.select_path(path)
|
||||
|
||||
def press(btn):
|
||||
user = app.getEntry("feideuser")
|
||||
password = app.getEntry("password")
|
||||
@@ -56,9 +64,18 @@ def press(btn):
|
||||
|
||||
app.stopLabelFrame()
|
||||
print(space)
|
||||
app.addButton("Download", download, space+2, 0)
|
||||
app.addButton("Select none", select_none, space+2, 1)
|
||||
app.addButton("Select all", select_all, space+2, 3)
|
||||
app.startLabelFrame("Select folder")
|
||||
app.addButton("Chose folder", select_folder, space+2, 0, 0)
|
||||
path = os.path.abspath(os.path.curdir)
|
||||
app.addLabel("path", path, space+2, 1)
|
||||
app.stopLabelFrame()
|
||||
app.startLabelFrame("Optional Actions")
|
||||
app.addButton("Select none", select_none, 0, 0, 0)
|
||||
app.addButton("Select all", select_all, 0, 1, 0)
|
||||
app.stopLabelFrame()
|
||||
app.startLabelFrame("Final step")
|
||||
app.addButton("Download", download, 0, 0, 2)
|
||||
app.stopLabelFrame()
|
||||
|
||||
app.startLabelFrame("It's Learning time")
|
||||
app.setSticky("ew")
|
||||
@@ -71,5 +88,4 @@ app.addSecretEntry("password", 1 , 1)
|
||||
app.stopLabelFrame()
|
||||
app.addButton("Login", press, 2, 0, 2)
|
||||
app.setFocus("feideuser")
|
||||
|
||||
app.go()
|
||||
|
||||
@@ -7,6 +7,7 @@ import html2text
|
||||
import multiprocessing
|
||||
import bs4
|
||||
import getpass
|
||||
|
||||
from multiprocessing import Process
|
||||
from bs4 import BeautifulSoup as bs
|
||||
from getpass import getpass
|
||||
@@ -15,6 +16,7 @@ from getpass import getpass
|
||||
|
||||
base_url = "https://ntnu.itslearning.com/"
|
||||
folder_url = "https://ntnu.itslearning.com/Folder/processfolder.aspx?FolderID="
|
||||
|
||||
def make_folder(curpath, title):
|
||||
folder_path = os.path.join(curpath,title)
|
||||
#print("making dir:",folder_path)
|
||||
@@ -28,7 +30,9 @@ class itslearning_scraper():
|
||||
self.browser = ms.StatefulBrowser()
|
||||
self.html2text = html2text.HTML2Text()
|
||||
self.start_url = "https://innsida.ntnu.no/lms-ntnu"
|
||||
path = os.path.abspath(os.path.curdir)
|
||||
#path = os.path.abspath(os.path.curdir)
|
||||
|
||||
def select_path(self, path):
|
||||
newpath = os.path.join(path, "scraped")
|
||||
if not os.path.exists(newpath):
|
||||
os.makedirs(newpath)
|
||||
|
||||
Reference in New Issue
Block a user