如何使用C#填写Google表单 [英] How to fill Google form with C#

查看:169
本文介绍了如何使用C#填写Google表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

表单是多页的,例如 并且我尝试使用POST请求,但它仅适用于一页形式,

The form is multipaged, like this and I tried to use POST request, but it works only for one-paged form, check this subject. Maybe there are another ways?

推荐答案

尝试以下代码.

WebClient client = new WebClient();
var nameValue = new NameValueCollection();
nameValue.Add("entry.xxx", "VALUE");// You will find these in name (not id) attributes of the input tags 
nameValue.Add("entry.xxx", "VALUE");
nameValue.Add("entry.xxx", "VALUE");
nameValue.Add("entry.xxx", "VALUE");
nameValue.Add("pageHistory", "0,1,2");//Comma separated page indexes
Uri uri = new Uri("https://docs.google.com/forms/d/e/[FORM_ID]/formResponse");
byte[] response = client.UploadValues(uri, "POST", nameValue);
string result = Encoding.UTF8.GetString(response);

我尝试了3页.您可以有任意数量的页面我猜". 这将直接提交数据并返回来自Google表单的成功页面".

I tried this with 3 pages. You can have any number of pages "i guess". This will submit the data directly and return "Success page from google forms".

编辑

我还没有使用过从来没有像现在这样的Google表单",因此无法找到合适的方法来进行此操作,但这似乎很好.

I Have not worked with google forms "like never", so was not able to find a proper way to do this if there is any, but this seems to work just fine.

将其附加到您的uri中以选中多个复选框

Append this to your uri for multiple checkboxes

?entry.xxxx=Option+1&entry.xxxx=Option2 

entry.xxxx对于一个问题保持不变 如果您有多个问题和复选框,那么它将更改为此

entry.xxxx remains same for one question if you have multiple questions with check boxes then it would change to this

?entry.xxx=Option+1&entry.xxx=Option2&entry.zzz=Option+1&entry.zzz=Option2

值是复选框的标签 用(+)替换(空格)加上(选项1)中的任何类似内容

value is the lable of your check box replace (whitespace) with (+) plus if any like in (Option 1)

这篇关于如何使用C#填写Google表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆