Link to home
Start Free TrialLog in
Avatar of jimmylew52
jimmylew52Flag for United States of America

asked on

What does this python error mean?

Using python 3 in 2008R2:   I had some help getting this far but I do not understand the error at the bottom. Can someone help?

#We need urllib module
import urllib.parse
import urllib.request
#These are the user and password parameters, check that field names are the same at the page form and put your real user and password values on myuser and mypassword
params = urllib.parse.urlencode({'username': 'UID', 'password': 'password', 'submit' : 'login'})
#This is the url of the login page, put the real url here
site = ""
#We save the result of the post in variable f
f = urllib.request.urlopen(site, params)
#We read the result
result =
#We print the result, so we can see if we are logged in
#print result
result = open('c:\\phython.html',w)
#Finished, so we close f

Still getting error:

TypeError: POST data should be bytes or an iterable of bytes. It cannot be of type str.
Avatar of Walter Ritzel
Walter Ritzel
Flag of Brazil image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial