stylemooncat 0.0.1 → 0.0.2

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: 8c7e37b6424726cdec5907fa1fed3985228a2eca
4
- data.tar.gz: 2c42777971df54b19607c98cb352966f8c8313ce
3
+ metadata.gz: 64df36aa66038d47ee4c60665f3bc6668159cca2
4
+ data.tar.gz: 75eee9919b481fa2770b2896f2efc63590ffe286
5
5
  SHA512:
6
- metadata.gz: 1cae3ab2235f3022a2d54712b0591191dbb467aadcfb85ff80ad2e3505c5b4eaf839a907e32f803a5926417614e54869978fbaa36a6e0582be51ada006a0831a
7
- data.tar.gz: db75b57f6f91455db0cf1c5ff3df22b0d86b495c882c8f0b2bef3c7ca5c4765389a9c1d947950bc38117d438bc958b8ded05a2e2f0d797605c3c4faa6c69554d
6
+ metadata.gz: 9c966d17a66178097532e6834343300707545dc0cddb6f7aad86f5d822ce4695df6b67ae84d8b1ca25e78e8a152c3a1a466ab46411b7b6bb4079051bc45612a0
7
+ data.tar.gz: f80776ae3c3bcf27d851741d5af11e24ad3b7ea18bb68e845166e0b6efcf1b9a0475732a8fd7ecdcc88d5c6cad741cc83cff551c87d79c193f448fad4d05d851
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.get_top(ARGV[0])
6
+ puts @scraper.scrape(ARGV[0],ARGV[1])
@@ -13,6 +13,7 @@ module StyleMoonCat
13
13
  @@LAST_WEEK_URI = "#{@@BASE_URI}/PDList.asp?recommand=1312090002"
14
14
  @@SPECIAL_DISCOUNT_URI = "#{@@BASE_URI}/PDList.asp?recommand=1312090003"
15
15
 
16
+ @@ALL_ITEMS_URI = "#{@@BASE_URI}/PDList.asp?item1=00"
16
17
  @@TOP_URI = "#{@@BASE_URI}/PDList.asp?p1=01"
17
18
  @@BOTTOM_URI = "#{@@BASE_URI}/PDList.asp?p1=02"
18
19
  @@OUTER_URI = "#{@@BASE_URI}/PDList.asp?p1=03"
@@ -32,62 +33,31 @@ module StyleMoonCat
32
33
  # Regular ?
33
34
  @@TITLE_REGEX = /([.\p{Han}[a-zA-Z]]+)/
34
35
 
35
- def get_new_arrival(page)
36
- uri = uri_with_page(@@NEW_ARRIVALS_URI, page)
37
- body = fetch_data(uri)
38
- filter(body)
39
- end
40
-
41
- def get_last_week(page)
42
- uri = uri_with_page(@@LAST_WEEK_URI, page)
43
- body = fetch_data(uri)
44
- filter(body)
45
- end
46
-
47
- def get_special_discount(page)
48
- uri = uri_with_page(@@SPECIAL_DISCOUNT_URI, page)
49
- body = fetch_data(uri)
50
- filter(body)
51
- end
52
-
53
- def get_top(page)
54
- uri = uri_with_page(@@TOP_URI, page)
55
- body = fetch_data(uri)
56
- filter(body)
57
- end
58
-
59
- def get_bottom(page)
60
- uri = uri_with_page(@@BOTTOM_URI, page)
61
- body = fetch_data(uri)
62
- filter(body)
63
- end
64
-
65
- def get_outer(page)
66
- uri = uri_with_page(@@OUTER_URI, page)
67
- body = fetch_data(uri)
68
- filter(body)
69
- end
70
-
71
- def get_dress(page)
72
- uri = uri_with_page(@@DRESS_URI, page)
73
- body = fetch_data(uri)
74
- filter(body)
75
- end
76
-
77
- def get_shoes(page)
78
- uri = uri_with_page(@@SHOES_URI, page)
79
- body = fetch_data(uri)
80
- filter(body)
81
- end
82
-
83
- def get_bag(page)
84
- uri = uri_with_page(@@BAG_URI, page)
85
- body = fetch_data(uri)
86
- filter(body)
87
- end
88
-
89
- def get_accessories(page)
90
- uri = uri_with_page(@@ACCESSORIES_URI, page)
36
+ def scrape(category,page)
37
+ case category
38
+ when "newarrival"
39
+ uri = uri_with_page(@@NEW_ARRIVALS_URI, page)
40
+ when "lastweek"
41
+ uri = uri_with_page(@@LAST_WEEK_URI, page)
42
+ when "specialdiscount"
43
+ uri = uri_with_page(@@SPECIAL_DISCOUNT_URI, page)
44
+ when "top"
45
+ uri = uri_with_page(@@TOP_URI, page)
46
+ when "bottom"
47
+ uri = uri_with_page(@@BOTTOM_URI, page)
48
+ when "outer"
49
+ uri = uri_with_page(@@OUTER_URI, page)
50
+ when "dress"
51
+ uri = uri_with_page(@@DRESS_URI, page)
52
+ when "shose"
53
+ uri = uri_with_page(@@SHOES_URI, page)
54
+ when "bag"
55
+ uri = uri_with_page(@@BAG_URI, page)
56
+ when "accessories"
57
+ uri = uri_with_page(@@ACCESSORIES_URI, page)
58
+ else
59
+ uri = uri_with_page(@@ALL_ITEMS_URI, page)
60
+ end
91
61
  body = fetch_data(uri)
92
62
  filter(body)
93
63
  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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Even Chang
@@ -13,8 +13,9 @@ bindir: bin
13
13
  cert_chain: []
14
14
  date: 2015-12-19 00:00:00.000000000 Z
15
15
  dependencies: []
16
- description: This is a gem scraping StyleMoonCat's website and returns certain category's
17
- items with title,price,image,and link
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
18
19
  email:
19
20
  - kiki44552002@gmail.com
20
21
  - lmherrera86@gmail.com