我正在尝试使用 Ruby从uptobox.com下载我自己的文件。但是当验证码显示时我被卡住了(这只是span
用一些 Javascript 生成的 html-tag 中的随机数)。我认为下载计时器也可能存在一些问题。在第 3 页上它说"wrong captcha"
require 'rubygems'
require 'mechanize'
agent = Mechanize.new
page1 = agent.get("http://uptobox.com/pzlw7p8d651h")
form_page1 = page1.forms.first
page2 = form_page1.submit(form_page1.button_with(:name => "method_free"))
form_page2 = page2.form_with(:name => "F1")
captcha = page2.parser.search("td[@align='right']/div").inner_text
form_page2.field_with(:name => "code").value = captcha
p form_page2
// 60s has to pass before the button is enabled. the prog waits 70s
timeToWait = (page2.parser.search("*[id='countdown_str']/span").text).to_i + 10
p Time.now.getutc
sleep(timeToWait)
p Time.now.getutc
button = form_page2.button_with(:value => "Create Download Link")
page3 = agent.submit(form_page2,button)
p page3.content
我究竟做错了什么?