hulihanapplications / fletcher

A cross-website product information fetcher for ruby.
http://www.hulihanapplications.com
MIT License
53 stars 12 forks source link

Fletcher

Build Status

Fletcher is a cross-website product information fetcher. Just give fletcher a product's url and you'll get back a nice, uniform object that's easy to work with.

Features

Supported Websites

Installation

gem install fletcher

Usage

API

require "fletcher"

product  = Fletcher.fetch "http://www.amazon.com/Avenir-Deluxe-Unicycle-20-Inch-Wheel/dp/B00165Q9F8"

product.name # => "Avenir Deluxe Unicycle (20-Inch Wheel)"

product.description # => "A wonderful unicycle"

product.images.count # => 1
product.image # => {:src => "http://ecx.images-amazon.com/images/I/41b3TNb3uCL._SL500_AA300_.jpg", :alt => "Picture of Unicycle"}
product.image.src # => "http://ecx.images-amazon.com/images/I/41b3TNb3uCL._SL500_AA300_.jpg"

product.price # => #<Money cents:500 currency:USD>
product.price.to_f # => 5.0
product.price.format # => "$5.00"  
product.price.currency.symbol # => "$"

# Get Raw Nokogiri Document
product.doc.class.name # => Nokogiri::HTML::Document

# Get list of supported websites/services
Fletcher.models # => [:amazon, :ebay, :etsy, :thinkgeek, ...]

CLI

Get Product Details (defaults to yaml output):

$ fletcher fetch "http://www.amazon.com/Avenir-Deluxe-Unicycle-20-Inch-Wheel/dp/B00165Q9F8"

---
name: Avenir Deluxe Unicycle (20-Inch Wheel)
description: 'Amazon.com: Avenir Deluxe Unicycle (20-Inch Wheel): Sports & Outdoors'
price: $99.99
image:
  src: http://ecx.images-amazon.com/images/I/41b3TNb3uCL._SL500_AA280_.jpg
url: http://www.amazon.com/Avenir-Deluxe-Unicycle-20-Inch-Wheel/dp/B00165Q9F8

Get a single attribute of a product:

$ fletcher fetch --only name "http://www.amazon.com/Avenir-Deluxe-Unicycle-20-Inch-Wheel/dp/B00165Q9F8"
Avenir Deluxe Unicycle (20-Inch Wheel)

Get list of supported websites:

$ fletcher websites
Amazon
ThinkGeek
...

Run in debug mode:

fletcher fetch --debug "http://www.amazon.com/gp/product/B004HZYA6E/"

Attributes

The following attributes/method are available for a product:

Contributing

If you make any changes to fletcher, be sure to run the test suite before creating any pull requests.

bundle install
bundle exec rspec spec/