I’ve got this ruby script:
require 'mechanize'
agent = Mechanize.new
page = agent.get "http://www.speech.sri.com/projects/srilm/download.html"
form = page.forms.last
form.field_with(name: "name").value = "Hans Meier"
form.field_with(name: "org").value = "Meier AG"
form.field_with(name: "email").value = "hans.meier.org"
form.field_with(name: "address").value = "Baslerstrasse 32"
form.field_with(name: "file").value = "/project/srilm/srilm-1.6.0.tar.gz"
File.open('srilm.tgz') {|f| f.write agent.submit(form).body }
According to the intro page, the first part is easy, but I don’t know how to handle the form.field_with stuff.
1 Answer