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 +4 -4
- data/bin/stylemooncat +1 -1
- data/lib/stylemooncat/scraper.rb +17 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a54f9b509f66cc508ccac4f332d08ecf1a5dae5
|
4
|
+
data.tar.gz: 9c5bab38c5d8df2b131606b6b385cd3662095592
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c9aa78a16d7e3e946af31b991d5c02085455870218cdad6418a85d4bdc657f2e0f243810690eedde5b8f11d69b69a2828e8b169303186257c8b82b14b40d7ce
|
7
|
+
data.tar.gz: efccd9eb9c8df17ca84cd8024c477f6e4136aab681fb62677779d1258266c86293e79fbeba8a4d13b23fe1226397cf3aafc53b4bf4edceb0145fa42becb2b08c
|
data/bin/stylemooncat
CHANGED
data/lib/stylemooncat/scraper.rb
CHANGED
@@ -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.
|
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-
|
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
|
17
|
-
|
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
|