1

This is the URL to my google form: https://docs.google.com/forms/d/e/1FAIpQLSfhLUFVzPk48c-Mdbc1N1ImVAtsZ_8WaQESydWrXOsJvz2rRw/viewform

And here is the Python code that I have:

    import requests

    url = "https://docs.google.com/forms/d/e/1FAIpQLSfhLUFVzPk48c-Mdbc1N1ImVAtsZ_8WaQESydWrXOsJvz2rRw/formResponse"
    s = requests.Session()
    datos = {"entry.1155905730":"TRES", "entry.2110183202":"DOS", "fvv":1, 'draftResponse':[],'pageHistory':0}    
    x = s.post(url, data=datos)

I get empty responses in my google form, as if all the answers were blank.

What am I missing?

1 Answer 1

2

You need to send a post to get into the form before start filling, this is how you see the link you posted: https://docs.google.com/forms/d/e/1FAIpQLSfhLUFVzPk48c-Mdbc1N1ImVAtsZ_8WaQESydWrXOsJvz2rRw/viewform enter image description here

Try to use the DevTools inspector to try to reproduce the requests and responses, inspecting the 'Next' button and in the Network tab you could find the request that gets you into the form:

enter image description here

How to reproduce them with python? A cool site to transform the curl requests in python code curl.trillworks

Paste the request and send it!

In [1]: import requests 
   ...:  
   ...: headers = { 
   ...:     'authority': 'docs.google.com', 
   ...:     'cache-control': 'max-age=0', 
   ...:     'origin': 'https://docs.google.com', 
   ...:     'upgrade-insecure-requests': '1', 
   ...:     'content-type': 'application/x-www-form-urlencoded', 
   ...:     'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like 
   ...: Gecko) Chrome/79.0.3945.117 Safari/537.36', 
   ...:     'sec-fetch-user': '?1', 
   ...:     'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.
   ...: 8,application/signed-exchange;v=b3;q=0.9', 
   ...:     'x-chrome-connected': 'id=102279514883169871637,mode=0,enable_account_consistency=false,consist
   ...: ency_enabled_by_default=false', 
   ...:     'x-client-data': 'CJW2yQEIpbbJAQjEtskBCKmdygEI6qzKAQicrcoBCMuuygEIvbDKAQiOssoBCPe0ygEIl7XKAQiYt
   ...: coBCOy1ygEI4bbKARirpMoB', 
   ...:     'sec-fetch-site': 'same-origin', 
   ...:     'sec-fetch-mode': 'navigate', 
   ...: } 
   ...:  
   ...: data = { 
   ...:   'fvv': '1', 
   ...:   'draftResponse': '[null,null,"4300515041069574030"]\r\n', 
   ...:   'pageHistory': '0', 
   ...:   'fbzx': '4300515041069574030', 
   ...:   'continue': '1' 
   ...: } 
   ...:  
   ...: response = requests.post('https://docs.google.com/forms/u/0/d/e/1FAIpQLSfhLUFVzPk48c-Mdbc1N1ImVAtsZ
   ...: _8WaQESydWrXOsJvz2rRw/formResponse', headers=headers, data=data) 
   ...:  
In [2]: 'DOS' in response.text    # And boom!                                                                         
Out[2]: True
Sign up to request clarification or add additional context in comments.

4 Comments

Right! I have to get past the first form, but I don't understand. This post is now to go to the next form, and then I have to do the other post, right? Also, 'DOS' in response.text returns true. But so does anything else... I tried '1234' and 'ola' in response.text and both returned true.
Your question was What am I missing?, so I thought that you previously test the code you posted and works. The line with 'DOS' in the response text is to prove that you pass to the form, the response contains 'ola' because is also in the form and '1234' could be somewhere else
Sorry!!! I didn't understand your answer at first, but after a couple of tests, I get now what you said and you 100% responded to my question! If I could upvote you twice, I would. Thanks!!!
No problem dude (also hablo español :v) tell me if you have other doubts

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.