GithubHelp home page GithubHelp logo

lumir / fletcher Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hulihanapplications/fletcher

0.0 2.0 0.0 755 KB

A cross-website product information fetcher for ruby.

Home Page: http://www.hulihanapplications.com

License: MIT License

Shell 0.13% Ruby 99.87%

fletcher's Introduction

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

  • No third-party API access required (good for websites that don't even have API access)
  • Uses nokogiri for data parsing

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:

  • name - (String) The name of the product
  • description - (String) The product's description
  • price - (Money) A Money object representing the product's price. This makes converting exchange rates and math functionality easy to use.
  • image - (Hash) The main image of the product, if available. This is a hash containing standard HTML attributes: src, alt, width, height, etc.
  • images - (Array) An array of product images.
  • doc - The raw Nokogiri::HTML::Document object for the product. You can use this to pull other stuff from the product's page.

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/
  • Troubleshooting

    • fletcher uses vcr to save http requests for faster testing. To pull real-time http data, clear the vcr cache with rm -rf spec/vcr. Please clear this cache before making a pull request.

fletcher's People

Contributors

dhulihan avatar hulihanapplications avatar lumir avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.