Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 使用黄瓜/水豚,是否有一种非脆性的方法来筛选刮擦?_Ruby_Capybara_Nokogiri - Fatal编程技术网

Ruby 使用黄瓜/水豚,是否有一种非脆性的方法来筛选刮擦?

Ruby 使用黄瓜/水豚,是否有一种非脆性的方法来筛选刮擦?,ruby,capybara,nokogiri,Ruby,Capybara,Nokogiri,有谁知道有一个RubyGem,它能够以一种健壮的方式识别html字段名和“屏幕抓取”响应数据 我有一个运行Capybara的Ruby/Cucumber框架。我有导航UI和输入数据的功能文件。我有几个屏幕,我必须从中收集字段中的数据。为了做到这一点,我使用Nokogiri获取响应页面html,并对其进行解析。搜索字符串({node}在我下面的示例中)在浏览不同的html块时可能非常复杂和脆弱 page_html = Nokogiri::HTML.parse(session.html) block

有谁知道有一个RubyGem,它能够以一种健壮的方式识别html字段名和“屏幕抓取”响应数据

我有一个运行Capybara的Ruby/Cucumber框架。我有导航UI和输入数据的功能文件。我有几个屏幕,我必须从中收集字段中的数据。为了做到这一点,我使用Nokogiri获取响应页面html,并对其进行解析。搜索字符串({node}在我下面的示例中)在浏览不同的html块时可能非常复杂和脆弱

page_html = Nokogiri::HTML.parse(session.html)
block = page_html.xpath(path)
result = block.at_xpath("#{node}")["#{value}"]

您使用Nokogiri解析页面而不仅仅使用Capybara及其内置选择器(或您自己的自定义选择器)来查找感兴趣的节点并访问其上的值属性,这有什么原因吗?find().value-find(:field,'name of field.).value-etc.。就像@TomWalpole说的,如果你已经可以访问水豚的选择器,那么就没有理由使用Nokogiri。我只会在不需要遍历UI的情况下使用Nokogiri,我只需要页面的原始数据。您使用Nokogiri解析页面而不是使用Capybara及其内置选择器(或您自己的自定义选择器)查找您感兴趣的节点并访问其上的值属性,这有什么原因吗?find().value-find(:field,'name of field.).value-etc.。就像@TomWalpole说的,如果你已经可以访问水豚的选择器,那么就没有理由使用Nokogiri。我只会在不需要遍历UI的情况下使用Nokogiri,我只需要从页面获取原始数据。