使用Ruby机制填充表单

时间:2018-04-14 17:02:17

标签: ruby forms mechanize

我正试图找出如何使用Ruby mechanize gem从https://www.otodom.pl/填充表单,但它不起作用。我尝试了一些变种和推荐的解决方案,但仍然没有。问题是,当我提交表单时(我需要按值=“弗罗茨瓦夫”填写第一个字段),接下来,但是下一页是提交空表单的结果。为什么?如何正确设置此字段并在提交后转到正确的页面?

问候!

require 'mechanize'

agent = Mechanize.new
main_page = agent.get 'https://www.otodom.pl/'

form = main_page.form(:class => "form form-search")

form.field_with(:name=>"search[LOCATION]").value = "Wrocław"
form.fields.each{|f|
  puts f.name
  puts f.value
}

sec_page = form.submit

puts sec_page.uri.to_s

rows = sec_page.root.css(".col-md-content article")

rows.take(10).each do |row|
  title = row.at_css(".text-nowrap span").text.strip
  puts "#{title}"
end

1 个答案:

答案 0 :(得分:0)

我查看了该页面,据我所知,没有from keras.layers import Input, Dense from keras.models import Model global_average_pooling2d_7 = vgg19.get_layer('block5_pool') # shape=(?, 7, 7, 512) bn_conv1_model = Model(inputs=vgg19.input, outputs=global_average_pooling2d_7.output) new_model = Sequential() new_model.add(bn_conv1_model) new_model.add(vgg19top_model) new_model.summary() _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= model_12 (Model) <-VGG19 (None, 7, 7, 512) 20024384 _________________________________________________________________ sequential_6 (Sequential) (None, 133) 164863 ================================================================= Total params: 20,189,247 Trainable params: 164,863 Non-trainable params: 20,024,384 名为input。此外,表单值似乎是数字标识符,例如search[LOCATION]当字段显示Wrocław,dolnośląskie时,您可以在以下屏幕截图中看到:

input fields