Created
February 12, 2018 11:00
-
-
Save mokhdzanifaeq/22cda12b00a5da00de1c7bd37b6561d9 to your computer and use it in GitHub Desktop.
google form bot with weighted answer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os,sys | |
import requests | |
import re | |
import ast | |
import json | |
import time | |
from numpy.random import choice | |
loop = 102 | |
for i in xrange(loop): | |
a1 = choice(['Easy', 'Normal', 'Hard', 'Very hard'], p=[0.2, 0.4, 0.3, 0.1]) | |
a2 = choice(['Yes', 'No'], p=[0.8, 0.2]) | |
a3 = choice(['Disagree', 'Neither agree or disagree', 'Agree', 'Strongly agree'], p=[0.1, 0.3, 0.4, 0.2]) | |
a4 = choice(['Strongly disagree', 'Disagree', 'Neither agree or disagree', 'Agree'], p=[0.3, 0.4, 0.2, 0.1]) | |
a5 = 'Yes' | |
print str(i+1) + ': {' + ', '.join([a1, a2, a3, a4, a5]) + '}' | |
page = requests.get('https://docs.google.com/forms/d/e/1FAIpQLSfBsCtksbsA-C7URGZm0N1OPlfqjRskO5ji5b0tg60gj0pjyg/viewform') | |
resid = re.search('name="fbzx" value="(.*?)">', page.text).group(1) | |
#print resid | |
headers = { | |
'referer': 'https://docs.google.com/forms/d/e/1FAIpQLSfBsCtksbsA-C7URGZm0N1OPlfqjRskO5ji5b0tg60gj0pjyg/viewform?fbzx=' + resid | |
} | |
payload = { | |
'entry.1465663923': a1, | |
'entry.1871926632': a2, | |
'entry.121028461': a3, | |
'entry.1999554517': a4, | |
'entry.2101305509': a5, | |
'fvv': '1', | |
'draftResponse': '[null,null,"' + resid + '"]', | |
'pageHistory': '0', | |
'fbzx': resid | |
} | |
page = requests.post('https://docs.google.com/forms/d/e/1FAIpQLSfBsCtksbsA-C7URGZm0N1OPlfqjRskO5ji5b0tg60gj0pjyg/formResponse', | |
headers=headers, data=payload) | |
time.sleep(3) | |
#print page.text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment