I found a way to login to websites in python with urllib, but now I need to check to see if it actually works and logs me in, by finding the current url, and seeing if its changed. I've looked around alot, but everything I find is either outdated or just doesnt work for me. Here is my code:
import urllib2
import urllib
import cookielib
url = urllib2.urlopen('https://tandemfs.myschoolapp.com/app#login')
login_url = 'https://tandemfs.myschoolapp.com/app#login'
acc_pwd = {'login':'LogIn','Username':'lukeroberts2022','password':'Enderdude34'}
cj = cookielib.CookieJar() ## add cookies
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.addheaders = [('User-agent','Mozilla/5.0 \
(compatible; MSIE 6.0; Windows NT 5.1)')]
data = urllib.urlencode(acc_pwd)
try:
opener.open(login_url,data,10)
print 'log in - success!'
except:
print 'log in - times out!', login_url
print url.geturl()
I dont care what module it uses as long as it finds the current url.