book_price 0.0.1 → 0.0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b5bb364a2201d2c885c58069292c2d8d4971662
4
- data.tar.gz: 76688ed9da7d69175cd40373306a614f535d3a02
3
+ metadata.gz: 4e73c35504d0dd968f8f1585cfb236cc64f10e72
4
+ data.tar.gz: baa7f0f4d54478997c1c75bf99cf6f4a07e7e802
5
5
  SHA512:
6
- metadata.gz: 6985af62adf964b10d93dc1f61ed04fb541f542e73ecff61051eaecbeee070bf84c9a34ddd38844038e2bfd577fb5cf93a960048d68214fb5eda8e9d7fff0bba
7
- data.tar.gz: 6a4d3d55b6bdd695811b62c09f4140172faf7831a822b185367587f6eede534268f4f24548e51775c44d732a76cd9d43872a7ebedeef6cf6dfada79b508f71c2
6
+ metadata.gz: 901a81a692b82cdd7667f6daf320e7259bef166caebc4896725432fed0e37ce0af4e2c4bd88cd0f42eb5bfa4579ef7a4ec9b9b7c2aa583ed4a3e4e2c0be9b107
7
+ data.tar.gz: adb35a4d313c0d16ce47eb3c2b081f0d7cec44dac2c832c3ee764183d9fab6a9228c35a3c8ff34ff2a9a5916033a4d697099738e8d1096f3ed88569f87621b07
data/README.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # BookPrice
2
2
 
3
- TODO: Write a gem description
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
- TODO: Write usage instructions here
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
 
@@ -40,13 +40,14 @@ class BookPrice
40
40
  par.each do |value|
41
41
  case value
42
42
  when 'p'
43
- price = result_page.css("#ctl00_ContentPlaceHolder1_product_info div.Mboxes_cont div.PI_info h3:nth-child(13) span").text
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 h3:nth-child(14) span:nth-child(2)").text
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'
@@ -1,3 +1,3 @@
1
1
  module BookPrice
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: book_price
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ctxhou