Skip to content

Instantly share code, notes, and snippets.

@pwnall
Created October 6, 2013 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pwnall/6858837 to your computer and use it in GitHub Desktop.
Save pwnall/6858837 to your computer and use it in GitHub Desktop.
Mechanizing a Google Form
require 'mechanize'
loop do
agent = Mechanize.new
agent.user_agent_alias = 'Mac Safari'
puts "Fetching form"
page = agent.get "https://docs.google.com/forms/d/15a7OlkEn9qDCxyG23a4ilS6SRa0c61p4el222OFqRAk/viewform"
puts "Filling form"
form = page.form_with :id => "ss-form"
form.field_with(:name => "entry.2077221051").value = "trololol"
form.radiobutton_with(:name => "entry.1824489067").check
form.radiobutton_with(:name => "entry.2108721354").check
puts "Submitting form"
page2 = form.submit()
puts "Done"
puts page2.root
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment