http://casesearch.courts.state.md.us/inquiry/inquirySearchParam.jis
agent = Mechanize.new
form = agent.get("http://casesearch.courts.state.md.us/inquiry/inquiry-index.jsp").forms.first
form.checkbox_with(:name => /disclaimer/).check
page = form.submit
上述代码在上述网站上提交了discalimer。现在提交免责声明后,当我使用以下代码时..
p page.forms[2]
它应输出所有字段,包括名字,姓氏和所有列表[正如您在网站上看到的那样]但它没有这样做。相反,我只是获取有关文本框的信息。
谁能告诉我为什么?尽管form[2]
是该页面上包含大部分字段的特定表单?
答案 0 :(得分:0)
看起来form [3]包含您正在寻找的信息。你开始数到1而不是0吗?
require 'rubygems'
require 'mechanize'
agent = Mechanize.new
form = agent.get("http://casesearch.courts.state.md.us/inquiry/inquiry- index.jsp").forms.first
form.checkbox_with(:name => /disclaimer/).check
page = form.submit
p page.forms.count
# out puts 4
p page.forms[3]
# outputs what I think you need
#<Mechanize::Form
{name "inquiryFormByCaseNum"}
{method "POST"}
{action "/inquiry/inquiryByCaseNum.jis"}
{fields
#<Mechanize::Form::Text:0x000001011cd020
@name="caseId",
@node=