I get an attribute error on my code with the method = 'POST' of my urllib.request.Request
I already try different syntax :
POST = 'post'
method = POST
method = 'POST'
and others...
request_login = urllib.request.Request("https://www.netflix.com/fr/Login",
data = "userLoginId={}&password={}&rememberMe=false&flow=websiteSignUp&mode=login&action=loginAction&withFields=rememberMe%2CnextPage%2CuserLoginId%2Cpassword%2CcountryCode%2CcountryIsoCode&authURL=authURL%2FEcpWPKhtag%3D&nextPage=&showPassword=&countryCode=%2B33&countryIsoCode=FR".format(email, password),
headers ={"""
'Host': 'www.netflix.com',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'fr-FR',
'Accept-Encoding': 'gzip, deflate, br',
'Referer': 'https://www.netflix.com/fr/',
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': 330,
"""},
unverifiable = True,
method = POST)
output of error is :
Traceback (most recent call last):
File ".\checker netflix.py", line 44, in <module>
checkPassword(email,password)
File ".\checker netflix.py", line 23, in checkPassword
method = POST)
File "C:\Users\Naylor\AppData\Local\Programs\Python\Python37-32\lib\urllib\request.py", line 334, in __init__
for key, value in headers.items():
AttributeError: 'set' object has no attribute 'items'
I expect to success the request and parse the server response to see if the parameter of the data pass or be refused
The headers you're passing is a set containing a string:
headers ={"""
'Host': 'www.netflix.com',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'fr-FR',
'Accept-Encoding': 'gzip, deflate, br',
'Referer': 'https://www.netflix.com/fr/',
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': 330,
"""}
instead of a dictionary:
headers = {
'Host': 'www.netflix.com',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'fr-FR',
'Accept-Encoding': 'gzip, deflate, br',
'Referer': 'https://www.netflix.com/fr/',
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': 330,
}