Skip to content

Commit

Permalink
add user login
Browse files Browse the repository at this point in the history
  • Loading branch information
sigvartmh committed May 11, 2017
1 parent 896a8a2 commit c5035c4
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions itl_scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,29 @@
import re
import argparse
import requests as rq
from bs4 import BeautifulSoup as bs
import mechanicalsoup as ms

key = input("Enter sessionID: ")
print(key)
cookie={"JSESSIONID": key}
from bs4 import BeautifulSoup as bs
from getpass import getpass

url = "https://innsida.ntnu.no/lms-ntnu"
b = ms.StatefulBrowser()

login = input("Enter NTNU-username: ")
password = getpass("Enter your NTNU-password: ")
b.open(url)
b.select_form("form[name=f]")
b["feidename"]=login
b["password"]=password
b.submit_selected()
b.select_form("form[action=https://sats.itea.ntnu.no/sso-wrapper/feidelogin]")
b.submit_selected()
key = b.session.cookies.get_dict()

cookie={"JSESSIONID": key["JSESSIONID"]}
print(cookie)
login = "https://innsida.ntnu.no/lms-ntnu"

r = rq.get(login, cookies=cookie)
r = rq.get(url, cookies=cookie)
print(r.url)

tc = r.request.headers["Cookie"].split(";")
Expand All @@ -20,6 +34,8 @@

base_url = "https://ntnu.itslearning.com/"



url = input("Enter folder link: ")


Expand Down

0 comments on commit c5035c4

Please sign in to comment.