Google-Forms response with Python?

google-forms, python

Solution

First `pip install requests`

You have to post some specific form data to a specific url,you can use requests.The form_data dict params are correspondent to options,if you don't need some options,just remove it from form_data.

import requests
url = 'https://docs.google.com/forms/d/152CTd4VY9pRvLfeACOf6SmmtFAp1CL750Sx72Rh6HJ8/formResponse'
form_data = {'entry.2020959411':'18+ sollte absolute Pflicht sein',
            'entry.2020959411':'Alter sollte garkeine Rolle spielen',
            'entry.2020959411':'17+ wäre für mich vertretbar',
            'entry.2020959411':'16+ wäre für mich vertretbar',
            'entry.2020959411':'15+ wäre für mich vertretbar',
            'entry.2020959411':'Ausnahmen von der Regel - Dafür?',
            'entry.2020959411':'Ausnahmen von der Regel - Dagegen?',
            'entry.2020959411':'__other_option__',
            'entry.2020959411.other_option_response':'test',
            'draftResponse':[],
            'pageHistory':0}
user_agent = {'Referer':'https://docs.google.com/forms/d/152CTd4VY9pRvLfeACOf6SmmtFAp1CL750Sx72Rh6HJ8/viewform','User-Agent': "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36"}
r = requests.post(url, data=form_data, headers=user_agent)

Problem

I'm trying to write a Python-Script which makes it possible to submit responses in Google-Forms like this one: https://docs.google.com/forms/d/152CTd4VY9pRvLfeACOf6SmmtFAp1CL750Sx72Rh6HJ8/viewform But how to I actually send the POST and how can I find out, what this POST should actually contain?

Original source