Skip to content

Instantly share code, notes, and snippets.

@kiliankoe
Created November 10, 2015 17:56
Show Gist options
  • Save kiliankoe/b7efac873b2073ed5e47 to your computer and use it in GitHub Desktop.
Save kiliankoe/b7efac873b2073ed5e47 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
require 'mechanize'
mechanize = Mechanize.new
poll_name = ARGV[0]
options = ARGV.slice(1,ARGV.count)
# Create Dudle Page
page = mechanize.get('https://dudle.inf.tu-dresden.de')
create_dudle_form = page.forms.first
create_dudle_form['create_poll'] = poll_name
create_dudle_form.radiobutton_with(:id => 'chooseTime').checked = false
create_dudle_form.radiobutton_with(:id => 'chooseNormal').checked = true
page = create_dudle_form.submit
# Add and remove columns page
options.each do |opt|
option = page.forms.first
option['new_columnname'] = opt
page = option.submit
end
page = page.forms.last.click_button()
# Last page
puts "Poll \"#{poll_name}\": #{page.at('#humanReadableURL')['value']}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment