Google-Forms对Python的响应? [英] Google-Forms response with Python?
问题描述
我正在尝试编写一个Python脚本,以使其可以在像这样的Google表单中提交响应: https://docs.google.com/forms/d/152CTd4VY9pRvLfeACOf6SmmxFAp1CL750>
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
但是我该如何实际发送POST,以及如何找出该POST实际包含的内容?
But how to I actually send the POST and how can I find out, what this POST should actually contain?
推荐答案
第一个pip install requests
您必须将一些特定的表单数据发布到特定的url,您可以使用请求.form_data dict参数与选项相对应,如果不需要某些选项,只需将其从form_data中删除.
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)
这篇关于Google-Forms对Python的响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!