stylemooncat 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a42ed2436bd53ecb6aed6634736c14dc4897c0e7
4
- data.tar.gz: 5bbe0b1c0e5757ace6781c5419c3a1d99d8b7064
3
+ metadata.gz: 9a54f9b509f66cc508ccac4f332d08ecf1a5dae5
4
+ data.tar.gz: 9c5bab38c5d8df2b131606b6b385cd3662095592
5
5
  SHA512:
6
- metadata.gz: 22a0ff7cd21da30057cf5963b7b09fd5e200a700b6e793001233c95838f73150868244df42b1c58db218acb6b343674b73b280afad7446e1ee54b27bcfceb554
7
- data.tar.gz: 36b8f257406dbd5e67c29371f897ad2b5a8eb3a9ec6dbf7c42994cb4c71859d989dddd4636c2924cd78c7b28e07eee7dbb96d08698c66c77911da030295a9567
6
+ metadata.gz: 1c9aa78a16d7e3e946af31b991d5c02085455870218cdad6418a85d4bdc657f2e0f243810690eedde5b8f11d69b69a2828e8b169303186257c8b82b14b40d7ce
7
+ data.tar.gz: efccd9eb9c8df17ca84cd8024c477f6e4136aab681fb62677779d1258266c86293e79fbeba8a4d13b23fe1226397cf3aafc53b4bf4edceb0145fa42becb2b08c
data/bin/stylemooncat CHANGED
@@ -3,4 +3,4 @@
3
3
  require_relative '../lib/stylemooncat.rb'
4
4
 
5
5
  @scraper = StyleMoonCat::Scraper.new
6
- puts @scraper.scrape(ARGV[0],ARGV[1])
6
+ puts @scraper.scrape(ARGV[0],ARGV[1],ARGV[2],ARGV[3],ARGV[4])
@@ -33,7 +33,7 @@ module StyleMoonCat
33
33
  # Regular ?
34
34
  @@TITLE_REGEX = /([.\p{Han}[a-zA-Z]]+)/
35
35
 
36
- def scrape(category,page)
36
+ def scrape(category,page,keyword,price_from,price_to)
37
37
  case category
38
38
  when "newarrival"
39
39
  uri = uri_with_page(@@NEW_ARRIVALS_URI, page)
@@ -58,12 +58,27 @@ module StyleMoonCat
58
58
  else
59
59
  uri = uri_with_page(@@ALL_ITEMS_URI, page)
60
60
  end
61
+
62
+ if (keyword != "none") && (keyword != nil)
63
+ uri = uri_with_keyword(uri,keyword)
64
+ end
65
+ puts uri
61
66
  body = fetch_data(uri)
62
- filter(body)
67
+ filter_results = filter(body)
68
+ #filter with price if there are correct price parameters
69
+ if price_to!=nil && price_from!=nil && price_to.to_i >=price_from.to_i && price_from.to_i !=-1 && price_to.to_i !=-1
70
+ return filter_results.select{|x| x[:price].to_i<=price_to.to_i && x[:price].to_i>=price_from.to_i }
71
+ else
72
+ return filter_results
73
+ end
63
74
  end
64
75
 
65
76
 
66
77
  private
78
+ def uri_with_keyword(uri, keyword)
79
+ "#{uri}&keyword=#{keyword}"
80
+ end
81
+
67
82
  def uri_with_page(uri, page)
68
83
  "#{uri}&pageno=#{page}"
69
84
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stylemooncat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Even Chang
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-12-19 00:00:00.000000000 Z
14
+ date: 2015-12-29 00:00:00.000000000 Z
15
15
  dependencies: []
16
- description: This is a gem scraping StyleMoonCat's website.Input category name and
17
- page number,and it will return the items with title,price,image,and link in the
18
- page of the category
16
+ description: This is a gem scraping StyleMoonCat's website.Input category name,page
17
+ number,searcing keyword,and price range,and it will return the items with title,price,image,and
18
+ link in the page of the category
19
19
  email:
20
20
  - kiki44552002@gmail.com
21
21
  - lmherrera86@gmail.com