mirror of
https://github.com/KevinMidboe/ITLscraper.git
synced 2025-10-29 17:50:14 +00:00
minor fix
This commit is contained in:
1
app.py
1
app.py
@@ -1,3 +1,4 @@
|
|||||||
|
import appJar
|
||||||
from appJar import gui
|
from appJar import gui
|
||||||
from itl_scrape import itslearning_scraper
|
from itl_scrape import itslearning_scraper
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import argparse
|
|
||||||
import requests as rq
|
import requests as rq
|
||||||
import mechanicalsoup as ms
|
import mechanicalsoup as ms
|
||||||
import html2text
|
import html2text
|
||||||
@@ -35,19 +34,23 @@ class itslearning_scraper():
|
|||||||
|
|
||||||
def login(self, username, password):
|
def login(self, username, password):
|
||||||
self.browser.open(self.start_url)
|
self.browser.open(self.start_url)
|
||||||
self.browser.select_form("form[name=f]")
|
try:
|
||||||
self.browser["feidename"]=username
|
self.browser.select_form("form[name=f]")
|
||||||
self.browser["password"]=password
|
self.browser["feidename"]=username
|
||||||
self.browser.submit_selected()
|
self.browser["password"]=password
|
||||||
self.browser.select_form("form[action=https://sats.itea.ntnu.no/sso-wrapper/feidelogin]")
|
self.browser.submit_selected()
|
||||||
self.browser.submit_selected()
|
except:
|
||||||
|
print("Something weird happened")
|
||||||
self.key = self.browser.session.cookies.get_dict()
|
try:
|
||||||
self.jsession={"JSESSIONID": self.key["JSESSIONID"]}
|
self.browser.select_form("form[action=https://sats.itea.ntnu.no/sso-wrapper/feidelogin]")
|
||||||
resp = rq.get(self.start_url, cookies=self.jsession)
|
self.browser.submit_selected()
|
||||||
|
self.key = self.browser.session.cookies.get_dict()
|
||||||
self.get_cookies(resp)
|
self.jsession={"JSESSIONID": self.key["JSESSIONID"]}
|
||||||
self.find_all_courses()
|
resp = rq.get(self.start_url, cookies=self.jsession)
|
||||||
|
self.get_cookies(resp)
|
||||||
|
self.find_all_courses()
|
||||||
|
except:
|
||||||
|
print("Didn't get login redirect")
|
||||||
|
|
||||||
def get_cookies(self, resp):
|
def get_cookies(self, resp):
|
||||||
split_cookie = resp.request.headers["Cookie"].split(";")
|
split_cookie = resp.request.headers["Cookie"].split(";")
|
||||||
|
|||||||
Reference in New Issue
Block a user