book_price 0.0.1 → 0.0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +37 -2
- data/lib/book_price.rb +3 -2
- data/lib/book_price/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4e73c35504d0dd968f8f1585cfb236cc64f10e72
|
|
4
|
+
data.tar.gz: baa7f0f4d54478997c1c75bf99cf6f4a07e7e802
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 901a81a692b82cdd7667f6daf320e7259bef166caebc4896725432fed0e37ce0af4e2c4bd88cd0f42eb5bfa4579ef7a4ec9b9b7c2aa583ed4a3e4e2c0be9b107
|
|
7
|
+
data.tar.gz: adb35a4d313c0d16ce47eb3c2b081f0d7cec44dac2c832c3ee764183d9fab6a9228c35a3c8ff34ff2a9a5916033a4d697099738e8d1096f3ed88569f87621b07
|
data/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# BookPrice
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
只是想順便練寫個爬蟲,剛好發現沒有爬這些網路商店價格的gem.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Description
|
|
7
|
+
|
|
8
|
+
這個gem會透過[ISBN](http://zh.wikipedia.org/zh/%E5%9B%BD%E9%99%85%E6%A0%87%E5%87%86%E4%B9%A6%E5%8F%B7)去爬台灣部份網路書店的價格,目前支援 [博客來](http://www.books.com.tw/), [誠品](http://www.eslite.com/), [金石堂](http://www.kingstone.com.tw/)。
|
|
4
9
|
|
|
5
10
|
## Installation
|
|
6
11
|
|
|
@@ -18,7 +23,37 @@ Or install it yourself as:
|
|
|
18
23
|
|
|
19
24
|
## Usage
|
|
20
25
|
|
|
21
|
-
|
|
26
|
+
require 'book_price'
|
|
27
|
+
BookPrice.<store_name>(<isbn>, <parameter>)
|
|
28
|
+
|
|
29
|
+
### store_name
|
|
30
|
+
|
|
31
|
+
| function | 名稱 |
|
|
32
|
+
|-----------|---------|
|
|
33
|
+
| books | 博客來 |
|
|
34
|
+
| eslite | 誠品 |
|
|
35
|
+
| kingStone | 金石堂 |
|
|
36
|
+
|
|
37
|
+
### parameter
|
|
38
|
+
|
|
39
|
+
| parameter | explain |
|
|
40
|
+
|-----------|----------------|
|
|
41
|
+
| p | origin price |
|
|
42
|
+
| d | discount price |
|
|
43
|
+
| n | name |
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### example
|
|
47
|
+
1. 抓`誠品`原始價格, 折價, 書名
|
|
48
|
+
|
|
49
|
+
BookPrice.eslite("9999000914138", "npd")
|
|
50
|
+
=> {"name"=>"控制 (電影書衣版)", "price"=>"399", "discount"=>"315"}
|
|
51
|
+
|
|
52
|
+
2. 抓`博客來` 折價
|
|
53
|
+
|
|
54
|
+
BookPrice.books("9999000914138", "d")
|
|
55
|
+
=> {"discount"=>"315"}
|
|
56
|
+
|
|
22
57
|
|
|
23
58
|
## Contributing
|
|
24
59
|
|
data/lib/book_price.rb
CHANGED
|
@@ -40,13 +40,14 @@ class BookPrice
|
|
|
40
40
|
par.each do |value|
|
|
41
41
|
case value
|
|
42
42
|
when 'p'
|
|
43
|
-
|
|
43
|
+
|
|
44
|
+
price = result_page.css("#ctl00_ContentPlaceHolder1_product_info div.Mboxes_cont div.PI_info .price").text
|
|
44
45
|
rtn_hash.store("price", price)
|
|
45
46
|
when 'n'
|
|
46
47
|
name = result_page.css("#ctl00_ContentPlaceHolder1_lblProductName").text.strip
|
|
47
48
|
rtn_hash.store("name", name)
|
|
48
49
|
when 'd'
|
|
49
|
-
discount = result_page.css("#ctl00_ContentPlaceHolder1_product_info div.Mboxes_cont div.PI_info
|
|
50
|
+
discount = result_page.css("#ctl00_ContentPlaceHolder1_product_info div.Mboxes_cont div.PI_info span.price_sale:nth-child(2)").text
|
|
50
51
|
rtn_hash.store("discount", discount)
|
|
51
52
|
else
|
|
52
53
|
raise 'wrong parameter'
|
data/lib/book_price/version.rb
CHANGED