I am trying to make a script which will fill the google form using post method. Here is my code:-
import urllib.parse
import urllib.request
user_agent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'
header={'User-Agent' : user_agent}
url = "https://docs.google.com/forms/d/e/1FAIpQLSec7NTUhCXGqeBxUfNraWHAd2Kf8aHg0tVy3fY0*****TF2Kw/"
# values from your form. You will need to include any hidden variables if you want to..
values= {
'Name to display': 'Mayank Test',
'Age':'22',
'Country':'India',
'Username':'user_mayank',
'Email (to share guidelines and confirming username and password)':'*****@gmail.com'
}
data = urllib.parse.urlencode(values).encode("utf-8")
req = urllib.request.Request(url, data)
response = urllib.request.urlopen(req)
the_page = response.read()
and I am getting error:-
Traceback (most recent call last):
File "C:/Users/MAYANK/Desktop/script_google_form.py", line 17, in <module>
response = urllib.request.urlopen(req)
File "I:\Python\lib\urllib\request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "I:\Python\lib\urllib\request.py", line 532, in open
response = meth(req, response)
File "I:\Python\lib\urllib\request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "I:\Python\lib\urllib\request.py", line 570, in error
return self._call_chain(*args)
File "I:\Python\lib\urllib\request.py", line 504, in _call_chain
result = func(*args)
File "I:\Python\lib\urllib\request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 405: Method Not Allowed
I dont know here I am wrong. Help me!! I dont know why not accepting post request