ruby 中的网络爬虫 [英] Web crawler in ruby
问题描述
您对用 Ruby 编写网络爬虫有什么建议?有比机械化更好的库吗?
What is your recommendation of writing a web crawler in Ruby? Any lib better than mechanize?
推荐答案
如果你只想获取页面的内容,最简单的方法是使用 open-uri
函数.他们不需要额外的宝石.你只需要 require 'open-uri'
和... http://ruby-doc.org/stdlib-2.2.2/libdoc/open-uri/rdoc/OpenURI.html
If you want just to get pages' content, the simpliest way is to use open-uri
functions. They don't require additional gems. You just have to require 'open-uri'
and... http://ruby-doc.org/stdlib-2.2.2/libdoc/open-uri/rdoc/OpenURI.html
要解析内容,您可以使用 Nokogiri 或其他 gem,例如,它们也可以具有有用的
To parse content you can use Nokogiri or other gems, which also can have, for example, useful XPATH-technology. You can find other parsing libraries just here on SO.
这篇关于ruby 中的网络爬虫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!