Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道是否可以在没有 Nokogiri 的情况下使用 Ruby Mechanize?我从不明确使用 Nokogiri。
也许它会快一点,至少是应用程序的启动?
不,没有 Nokogiri 就不能使用 Mechanize。Nokogiri 是 Mechanize 的先决条件,也是 Mechanize 如何定位 HTML 页面内的各个部分。
如果在您编写的使用 Mechanize 的代码中,您有单独的require 'nokogiri'语句,则可以删除该行。机械化仍将自动需要它,因此您不需要这样做。如果您需要使用 Nokogiri 来解析 Mechanize 检索到的部分文档,您可以通过 Mechanize 的page方法来完成。
require 'nokogiri'
page