0
我有了這個Ruby腳本:的Ruby腳本機械化在Python
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 }
按照intro page,第一部分是容易的,但我不知道如何處理form.field_with
東西。
從技術上講,這不等同於'field_with'(它允許多條件或正則表達式匹配),但是OP並沒有真正需要在Ruby腳本中使用它。 – 2011-12-18 21:04:32