机械化。红宝石。无法获得具有隐藏字段的动态内容的下拉菜单

时间:2013-07-21 14:09:53

标签: ruby drop-down-menu web-scraping mechanize hidden

我没有经验丰富的Ruby + Mechanize,刚刚开始,所以...请帮忙。 我试图用动态内容填写表单。但是我不能一步一步地做到这一点。

那是我的代码:

#!/usr/bin/env ruby
# encoding: utf-8

require 'rubygems'
require 'mechanize'
require 'logger'

url = "https://visapoint.eu/visapoint2/disclaimer.aspx"
agent = Mechanize.new
agent.user_agent_alias = 'Mac Safari'
agent.log = Logger.new(STDOUT)

page = agent.get(url)
page.encoding = 'utf-8'

# Disclamer.aspx object page
disclamer_page = agent.page

# Click Accept button on Disclamer.aspx
accept_button = disclamer_page.form.button_with(:value =>'Accept')
action_page = disclamer_page.form.click_button( accept_button )

# Click New Appointment button on Action.aspx
new_appointment_button = action_page.form.button_with(:name => 'ctl00$cphMain$btnNewAppointment_input')
form_page = action_page.form.click_button ( new_appointment_button )

# Fill form on Form.aspx page
form_page.form['ctl00$cphMain$ddCitizenship'] = "Kazakhstan (Қазақстан)"
form_page.form['ctl00$cphMain$ddCountryOfResidence'] = "Kazakhstan (Қазақстан)"
form_page.form['ctl00$cphMain$ddEmbassy'] = "#Kazakhstan (Қазақстан) - Astana"
form_page.form['ctl00$cphMain$ddVisaType'] = "Long-stay visa for study"
pp form_page.form
formpage_next = agent.submit(form_page.form, form_page.form.buttons.last)

pp formpage_next

发送form_page后,我希望重新加载的页面有验证码,但那里什么都没有。

0 个答案:

没有答案