I'm having issues logging into a website with Python. I just want to login to the site, then get the raw html of a page that you can only see when logged in so I can parse it with BeautifulSoup. I've tried using the answer at How to use Python to login to a webpage and retrieve cookies for later usage? but it doesn't seem to work.
I looked at the POST data required using LiveHeaders, and I think I'm setting it properly but my code just returns the login page.
Anyone know what I'm doing wrong?
import http.cookiejar
import urllib.request
import urllib.parse
username = 'username'
password = 'password'
_type = 'g'
vcode = ''
cj = http.cookiejar.CookieJar()
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
login_data = urllib.parse.urlencode({'username' : username, 'password' : password, 'type' : _type, 'vcode': vcode})
login_data = login_data.encode('ascii')
opener.open('http://passthepopcorn.me/login.php', login_data)
resp = opener.open('http://passthepopcorn.me/requests.php')
print(resp.read())