BookPrice
只是想順便練寫個爬蟲,剛好發現沒有爬這些網路商店價格的gem.
Description
這個gem會透過ISBN去爬台灣部份網路書店的價格,目前支援 博客來, 誠品, 金石堂。
Installation
Add this line to your application's Gemfile:
gem 'book_price'
And then execute:
$ bundle
Or install it yourself as:
$ gem install book_price
Usage
require 'book_price'
BookPrice.<store_name>(<isbn>, <parameter>)
store_name
function | 名稱 |
---|
books | 博客來 |
eslite | 誠品 |
kingStone | 金石堂 |
parameter
parameter | explain |
---|
p | origin price |
d | discount price |
n | name |
example
-
抓誠品
原始價格, 折價, 書名
BookPrice.eslite("9999000914138", "npd")
=> {"name"=>"控制 (電影書衣版)", "price"=>"399", "discount"=>"315"}
-
抓博客來
折價
BookPrice.books("9999000914138", "d")
=> {"discount"=>"315"}
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request