0.0
No commit activity in last 3 years
No release in over 3 years
Mongo support for Scruber
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
>= 1.6.0, ~> 1.6
~> 10.0
~> 3.0
= 3.0.1

Runtime

~> 2.4
~> 0.1.6
 Project Readme

Scruber-mongo

This gem provides Mongo support for Scruber

Installation

  1. Add this line to your application's Gemfile:
gem 'scruber-mongo'
  1. And then execute:

    $ bundle

  2. Install gem

    $ scruber generate mongo:install

This gem provides Queue driver, Output driver and FetcherAgent driver for mongo.

Sample scraper

Scruber.run do
  get "http://example.abc/product"
  
  parse :html do |page, doc|
    id = mongo_out_product title: doc.at('title').text

    get_reviews URI.join(page.url, doc.at('a.review_link').attr('href')).to_s, product_id: id
  end

  parse_reviews :html do |page,doc|
    product = mongo_find_product page.options[:product_id]

    product[:reviews] = doc.search('.review').map{|r| {author: r.at('.author').text, text: r.at('.text').text } }

    mongo_out_product product
  end
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/scruber/scruber-mongo.

License

The gem is available as open source under the terms of the MIT License.