ruby 中的网络爬虫 [英] Web crawler in ruby

查看:33
本文介绍了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,例如,它们也可以具有有用的 XPATH-技术.您可以在就在此处找到其他解析库.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆