What is your recommendation of writing a web crawler in Ruby? Any lib better than mechanize?
问题:
回答1:
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
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.
回答2:
I'd give a try to anemone. It's simple to use, especially if you have to write a simple crawler. In my opinion, It is well designed too. For example, I wrote a ruby script to search for 404 errors on my sites in a very short time.
回答3:
You might want to check out wombat that is built on top of Mechanize/Nokogiri and provides a DSL (like Sinatra, for example) to parse pages. Pretty neat :)
回答4:
I am working on pioneer gem which is not a spider, but a simple asynchronous crawler based on em-synchrony gem
回答5:
I just released one recently called Klepto. Its got a pretty simple DSL, is built on top of capybara and has lot of cool configuration options.