ktk*_*hik 7 ruby screen-scraping mechanize web-crawler
我正在构建一个爬虫,我正在使用Mechanize.我想点击一个单选按钮.我怎么做 ?
例如,有两个单选按钮说'A'和'B'.该网站自动选择B,但我想在红宝石中使用Mechanize'A'.我也在使用Mechanize的最新版本.
Ale*_*tie 14
有几种方法可以做到这一点.可能最好的方法是使用单选按钮name或id:
form.radiobutton_with(:name => /b/).check
Run Code Online (Sandbox Code Playgroud)
你也可以这样做:
form.radiobuttons.first.check
Run Code Online (Sandbox Code Playgroud)
哪个更简洁,但更容易破坏(例如,如果您要更改表单的设计).
| 归档时间: |
|
| 查看次数: |
5463 次 |
| 最近记录: |