shopee 1.0.0 → 1.0.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/bin/shopee +8 -0
- data/lib/data/mobile_category.rb +171 -1
- data/lib/shopee.rb +17 -8
- data/lib/shopee/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: 5e745a1cd1eadcf59c21089c07ed9f0942a57961
|
4
|
+
data.tar.gz: 80b853ab220ebc1534db2e01e644915e542b1e65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70f59d478752f94c7b8bf56d17bff314e70fd7c2e2628c60e42b9ca4e8932157527cffa026d2460d9354bb9c3fc3e558e7307709834e5089a133775c53e7a458
|
7
|
+
data.tar.gz: bcf504a14b42133fe7cd23bb03157029ae3c2e9a477179a27f07be187a85a55fdffb66a63fedc67cf1d8fa0f217ec0342febf033042f8097539c496410384f57
|
data/bin/shopee
CHANGED
@@ -41,5 +41,13 @@ Commander.configure do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
command :child do |c|
|
45
|
+
c.syntax = 'shopee child [category]'
|
46
|
+
c.description = 'Get sub-category.'
|
44
47
|
|
48
|
+
c.action do |args, options|
|
49
|
+
shopeecate = ShopeeScrape::ShopeeListGoodsByCate.new()
|
50
|
+
puts shopeecate.get_cate_childs(args[0])
|
51
|
+
end
|
52
|
+
end
|
45
53
|
end
|
data/lib/data/mobile_category.rb
CHANGED
@@ -140,4 +140,174 @@ ALL_LINK = { "電腦資訊"=>"http://www.mobile01.com/mpcatlist.php?c=1",
|
|
140
140
|
"南部地區"=>"http://www.mobile01.com/mpcatlist.php?c=90",
|
141
141
|
"東部與外島地區"=>"http://www.mobile01.com/mpcatlist.php?c=91"
|
142
142
|
}
|
143
|
-
|
143
|
+
|
144
|
+
CATE_TREE = {
|
145
|
+
"電腦資訊" => {
|
146
|
+
"桌上型電腦"=>"http://www.mobile01.com/mpcatlist.php?c=9",
|
147
|
+
"核心組件"=>"http://www.mobile01.com/mpcatlist.php?c=11",
|
148
|
+
"儲存裝置"=>"http://www.mobile01.com/mpcatlist.php?c=58",
|
149
|
+
"顯示設備"=>"http://www.mobile01.com/mpcatlist.php?c=59",
|
150
|
+
"網路設備"=>"http://www.mobile01.com/mpcatlist.php?c=60",
|
151
|
+
"電腦周邊設備"=>"http://www.mobile01.com/mpcatlist.php?c=13",
|
152
|
+
"機殼、散熱與電源"=>"http://www.mobile01.com/mpcatlist.php?c=62",
|
153
|
+
"電腦軟體與書籍"=>"http://www.mobile01.com/mpcatlist.php?c=12",
|
154
|
+
"耗材、線材與雜項"=>"http://www.mobile01.com/mpcatlist.php?c=61",
|
155
|
+
"筆記型電腦"=>"http://www.mobile01.com/mpcatlist.php?cir=10",
|
156
|
+
"筆記型電腦周邊"=>"http://www.mobile01.com/mpcatlist.php?c=56",
|
157
|
+
"平板電腦"=>"http://www.mobile01.com/mpcatlist.php?c=55",
|
158
|
+
"蘋果電腦"=>"http://www.mobile01.com/mpcatlist.php?c=54",
|
159
|
+
"蘋果電腦周邊"=>"http://www.mobile01.com/mpcatlist.php?c=57",
|
160
|
+
"其它"=>"http://www.mobile01.com/mpcatlist.php?c=116"
|
161
|
+
},
|
162
|
+
|
163
|
+
"手持通訊" => {
|
164
|
+
"手機"=>"http://www.mobile01.com/mpcatlist.php?c=14",
|
165
|
+
"Android"=>"http://www.mobile01.com/mpcatlist.php?c=20000001",
|
166
|
+
"iPhone"=>"http://www.mobile01.com/mpcatlist.php?c=20000002",
|
167
|
+
"Windows Phone"=>"http://www.mobile01.com/mpcatlist.php?c=20000003",
|
168
|
+
"其他類型"=>"http://www.mobile01.com/mpcatlist.php?c=20000005",
|
169
|
+
"手機配件與吊飾"=>"http://www.mobile01.com/mpcatlist.php?c=63",
|
170
|
+
"家用電話"=>"http://www.mobile01.com/mpcatlist.php?c=64",
|
171
|
+
"傳真、影印與事務機"=>"http://www.mobile01.com/mpcatlist.php?c=65",
|
172
|
+
"通訊週邊與耗材"=>"http://www.mobile01.com/mpcatlist.php?c=17",
|
173
|
+
"GPS"=>"http://www.mobile01.com/mpcatlist.php?c=16"
|
174
|
+
},
|
175
|
+
|
176
|
+
"攝影器材" => {
|
177
|
+
"攝影機"=>"http://www.mobile01.com/mpcatlist.php?c=20",
|
178
|
+
"傳統底片相機"=>"http://www.mobile01.com/mpcatlist.php?c=70",
|
179
|
+
"消費級數位相機"=>"http://www.mobile01.com/mpcatlist.php?c=19",
|
180
|
+
"數位單眼相機"=>"http://www.mobile01.com/mpcatlist.php?c=18",
|
181
|
+
"相機其他周邊"=>"http://www.mobile01.com/mpcatlist.php?c=22",
|
182
|
+
"相機鏡頭"=>"http://www.mobile01.com/mpcatlist.php?c=67",
|
183
|
+
"攝影背包"=>"http://www.mobile01.com/mpcatlist.php?c=51",
|
184
|
+
"數位相機電池"=>"http://www.mobile01.com/mpcatlist.php?c=68",
|
185
|
+
"數位相機充電器"=>"http://www.mobile01.com/mpcatlist.php?c=69",
|
186
|
+
"記憶卡與行動相簿"=>"http://www.mobile01.com/mpcatlist.php?c=71",
|
187
|
+
"相片印表機與數位相框"=>"http://www.mobile01.com/mpcatlist.php?c=21"
|
188
|
+
},
|
189
|
+
|
190
|
+
"數位家電" => {
|
191
|
+
"電視機"=>"http://www.mobile01.com/mpcatlist.php?c=23",
|
192
|
+
"音響與隨身聽"=>"http://www.mobile01.com/mpcatlist.php?c=75",
|
193
|
+
"影音設備周邊"=>"http://www.mobile01.com/mpcatlist.php?c=24",
|
194
|
+
"投影機與布幕"=>"http://www.mobile01.com/mpcatlist.php?c=72",
|
195
|
+
"生活小家電"=>"http://www.mobile01.com/mpcatlist.php?c=25",
|
196
|
+
"廚房小家電"=>"http://www.mobile01.com/mpcatlist.php?c=76",
|
197
|
+
"淨水設備"=>"http://www.mobile01.com/mpcatlist.php?c=74",
|
198
|
+
"健康與美容小家電"=>"http://www.mobile01.com/mpcatlist.php?c=77",
|
199
|
+
"冰箱"=>"http://www.mobile01.com/mpcatlist.php?c=78",
|
200
|
+
"洗衣與乾衣機"=>"http://www.mobile01.com/mpcatlist.php?c=79",
|
201
|
+
"冷氣空調"=>"http://www.mobile01.com/mpcatlist.php?c=80"
|
202
|
+
},
|
203
|
+
|
204
|
+
"休閒娛樂" => {
|
205
|
+
"電玩主機"=>"http://www.mobile01.com/mpcatlist.php?c=27",
|
206
|
+
"電玩遊戲"=>"http://www.mobile01.com/mpcatlist.php?c=73",
|
207
|
+
"動漫電玩週邊"=>"http://www.mobile01.com/mpcatlist.php?c=85",
|
208
|
+
"電腦與線上遊戲"=>"http://www.mobile01.com/mpcatlist.php?c=26",
|
209
|
+
"懷舊童玩"=>"http://www.mobile01.com/mpcatlist.php?c=83",
|
210
|
+
"遙控模型"=>"http://www.mobile01.com/mpcatlist.php?c=81",
|
211
|
+
"金屬與鐵道模型"=>"http://www.mobile01.com/mpcatlist.php?c=82",
|
212
|
+
"益智遊戲"=>"http://www.mobile01.com/mpcatlist.php?c=84",
|
213
|
+
"玩具與模型"=>"http://www.mobile01.com/mpcatlist.php?c=29",
|
214
|
+
"書籍雜誌"=>"http://www.mobile01.com/mpcatlist.php?c=30",
|
215
|
+
"電視電影"=>"http://www.mobile01.com/mpcatlist.php?c=31",
|
216
|
+
"音樂歌曲"=>"http://www.mobile01.com/mpcatlist.php?c=32"
|
217
|
+
},
|
218
|
+
|
219
|
+
"生活用品" => {
|
220
|
+
"名產美食"=>"http://www.mobile01.com/mpcatlist.php?c=47",
|
221
|
+
"運動健身綜合"=>"http://www.mobile01.com/mpcatlist.php?c=34",
|
222
|
+
"休閒旅遊"=>"http://www.mobile01.com/mpcatlist.php?c=35",
|
223
|
+
"鐘錶名品"=>"http://www.mobile01.com/mpcatlist.php?c=872",
|
224
|
+
"生活居家"=>"http://www.mobile01.com/mpcatlist.php?c=38",
|
225
|
+
"寵物用品"=>"http://www.mobile01.com/mpcatlist.php?c=86"
|
226
|
+
},
|
227
|
+
|
228
|
+
"汽車" => {
|
229
|
+
"轎車、跑車"=>"http://www.mobile01.com/mpcatlist.php?c=1309",
|
230
|
+
"休旅車"=>"http://www.mobile01.com/mpcatlist.php?c=1310",
|
231
|
+
"貨車、其他車種"=>"http://www.mobile01.com/mpcatlist.php?c=1311",
|
232
|
+
"汽車用品"=>"http://www.mobile01.com/mpcatlist.php?c=130000001",
|
233
|
+
"汽車精品"=>"http://www.mobile01.com/mpcatlist.php?c=1312",
|
234
|
+
"美容清潔"=>"http://www.mobile01.com/mpcatlist.php?c=1313",
|
235
|
+
"油品"=>"http://www.mobile01.com/mpcatlist.php?c=1314",
|
236
|
+
"其他汽車用品"=>"http://www.mobile01.com/mpcatlist.php?c=1315",
|
237
|
+
"影音設備"=>"http://www.mobile01.com/mpcatlist.php?c=1316",
|
238
|
+
"汽車零件"=>"http://www.mobile01.com/mpcatlist.php?c=130000002",
|
239
|
+
"車燈"=>"http://www.mobile01.com/mpcatlist.php?c=1317",
|
240
|
+
"輪胎、鋁圈"=>"http://www.mobile01.com/mpcatlist.php?c=1318",
|
241
|
+
"底盤系統"=>"http://www.mobile01.com/mpcatlist.php?c=1319",
|
242
|
+
"電機、冷卻系統"=>"http://www.mobile01.com/mpcatlist.php?c=1320",
|
243
|
+
"煞車系統"=>"http://www.mobile01.com/mpcatlist.php?c=1321",
|
244
|
+
"空力套件"=>"http://www.mobile01.com/mpcatlist.php?c=1322",
|
245
|
+
"引擎、傳動與其它"=>"http://www.mobile01.com/mpcatlist.php?c=1323"
|
246
|
+
},
|
247
|
+
|
248
|
+
"機車" => {
|
249
|
+
"機車騎士用品"=>"http://www.mobile01.com/mpcatlist.php?c=1324",
|
250
|
+
"機車用品"=>"http://www.mobile01.com/mpcatlist.php?c=52",
|
251
|
+
"機車零組件"=>"http://www.mobile01.com/mpcatlist.php?c=53"
|
252
|
+
},
|
253
|
+
|
254
|
+
"自行車" => {
|
255
|
+
"公路車"=>"http://www.mobile01.com/mpcatlist.php?c=93",
|
256
|
+
"登山車"=>"http://www.mobile01.com/mpcatlist.php?c=92",
|
257
|
+
"小徑與摺疊車"=>"http://www.mobile01.com/mpcatlist.php?c=94",
|
258
|
+
"休閒與通勤車"=>"http://www.mobile01.com/mpcatlist.php?c=41",
|
259
|
+
"人身部品"=>"http://www.mobile01.com/mpcatlist.php?c=11700001",
|
260
|
+
"安全帽"=>"http://www.mobile01.com/mpcatlist.php?c=126",
|
261
|
+
"車衣、車褲"=>"http://www.mobile01.com/mpcatlist.php?c=127",
|
262
|
+
"其它人身部品"=>"http://www.mobile01.com/mpcatlist.php?c=128",
|
263
|
+
"自行車用品"=>"http://www.mobile01.com/mpcatlist.php?c=11700002",
|
264
|
+
"車燈、碼表"=>"http://www.mobile01.com/mpcatlist.php?c=129",
|
265
|
+
"收納袋、車袋"=>"http://www.mobile01.com/mpcatlist.php?c=130",
|
266
|
+
"清潔保養用品"=>"http://www.mobile01.com/mpcatlist.php?c=131",
|
267
|
+
"其它周邊配件"=>"http://www.mobile01.com/mpcatlist.php?c=132",
|
268
|
+
"自行車零件"=>"http://www.mobile01.com/mpcatlist.php?c=11700003",
|
269
|
+
"車架、前叉、避震器"=>"http://www.mobile01.com/mpcatlist.php?c=133",
|
270
|
+
"龍頭、車把"=>"http://www.mobile01.com/mpcatlist.php?c=134",
|
271
|
+
"煞車、變速系統零件"=>"http://www.mobile01.com/mpcatlist.php?c=135",
|
272
|
+
"輪組、內外胎"=>"http://www.mobile01.com/mpcatlist.php?c=136",
|
273
|
+
"座墊、座管"=>"http://www.mobile01.com/mpcatlist.php?c=137",
|
274
|
+
"其它車用零件"=>"http://www.mobile01.com/mpcatlist.php?c=138"
|
275
|
+
},
|
276
|
+
|
277
|
+
"男性時尚" => {
|
278
|
+
"服飾與襯衫"=>"http://www.mobile01.com/mpcatlist.php?c=866",
|
279
|
+
"外套與夾克"=>"http://www.mobile01.com/mpcatlist.php?c=867",
|
280
|
+
"男用長短褲"=>"http://www.mobile01.com/mpcatlist.php?c=868",
|
281
|
+
"男用鞋與靴"=>"http://www.mobile01.com/mpcatlist.php?c=869",
|
282
|
+
"男性內衣褲襪"=>"http://www.mobile01.com/mpcatlist.php?c=870",
|
283
|
+
"男性飾品與配件"=>"http://www.mobile01.com/mpcatlist.php?c=871"
|
284
|
+
},
|
285
|
+
|
286
|
+
"女性流行" => {
|
287
|
+
"彩妝與保養"=>"http://www.mobile01.com/mpcatlist.php?c=36",
|
288
|
+
"嬰幼童與母親"=>"http://www.mobile01.com/mpcatlist.php?c=37",
|
289
|
+
"流行女裝"=>"http://www.mobile01.com/mpcatlist.php?c=43",
|
290
|
+
"女性飾品與配件"=>"http://www.mobile01.com/mpcatlist.php?c=44",
|
291
|
+
"女鞋"=>"http://www.mobile01.com/mpcatlist.php?c=45",
|
292
|
+
"女性內衣"=>"http://www.mobile01.com/mpcatlist.php?c=46"
|
293
|
+
},
|
294
|
+
|
295
|
+
"代購與虛擬物品" => {
|
296
|
+
"3C物品代購"=>"http://www.mobile01.com/mpcatlist.php?c=240",
|
297
|
+
"動漫電玩代購"=>"http://www.mobile01.com/mpcatlist.php?c=241",
|
298
|
+
"服飾配件代購"=>"http://www.mobile01.com/mpcatlist.php?c=242",
|
299
|
+
"其他物品代購"=>"http://www.mobile01.com/mpcatlist.php?c=243",
|
300
|
+
"手機門號/加值/預付卡"=>"http://www.mobile01.com/mpcatlist.php?c=244",
|
301
|
+
"遊戲點卡/虛寶"=>"http://www.mobile01.com/mpcatlist.php?c=245",
|
302
|
+
"票卷"=>"http://www.mobile01.com/mpcatlist.php?c=246"
|
303
|
+
},
|
304
|
+
|
305
|
+
"房屋地產" => {
|
306
|
+
"北部地區"=>"http://www.mobile01.com/mpcatlist.php?c=88",
|
307
|
+
"中部地區"=>"http://www.mobile01.com/mpcatlist.php?c=89",
|
308
|
+
"南部地區"=>"http://www.mobile01.com/mpcatlist.php?c=90",
|
309
|
+
"東部與外島地區"=>"http://www.mobile01.com/mpcatlist.php?c=91"
|
310
|
+
}
|
311
|
+
}
|
312
|
+
|
313
|
+
# CATEGORY_LIST = ["電腦資訊", "手持通訊", "攝影器材", "數位家電", "休閒旅遊", "生活用品", "汽車", "機車", "自行車", "男性時尚", "女性流行", "代購與虛擬物品", "房屋地產"]
|
data/lib/shopee.rb
CHANGED
@@ -18,7 +18,6 @@ module ShopeeScrape
|
|
18
18
|
GOOD_UPTIME = "//div[contains(@class, 'updated')]"
|
19
19
|
|
20
20
|
def initialize(category=nil, page=nil)
|
21
|
-
puts category, page
|
22
21
|
if !category.nil? && !page.nil?
|
23
22
|
get_page_html(category, page)
|
24
23
|
end
|
@@ -32,19 +31,30 @@ module ShopeeScrape
|
|
32
31
|
@similar ||= find_similiar_goods(category, keyword, list_num)
|
33
32
|
end
|
34
33
|
|
34
|
+
def get_cate_childs(cate=nil)
|
35
|
+
childs = []
|
36
|
+
if !cate.nil?
|
37
|
+
CATE_TREE[cate].each do |k, v|
|
38
|
+
childs << {k => v}
|
39
|
+
end
|
40
|
+
childs
|
41
|
+
else
|
42
|
+
childs
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
35
46
|
private
|
36
47
|
|
37
48
|
def get_page_html(cate, page)
|
38
49
|
@document = []
|
39
50
|
url = ALL_LINK[cate]
|
40
51
|
|
41
|
-
if
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
@document << Oga.parse_html(open(url))
|
46
|
-
end
|
52
|
+
if page != 1
|
53
|
+
@document << Oga.parse_html(open(url << '&p=' << page.to_s))
|
54
|
+
else
|
55
|
+
@document << Oga.parse_html(open(url))
|
47
56
|
end
|
57
|
+
|
48
58
|
end
|
49
59
|
|
50
60
|
def extract_goods
|
@@ -99,7 +109,6 @@ module ShopeeScrape
|
|
99
109
|
|
100
110
|
end
|
101
111
|
|
102
|
-
puts results.length
|
103
112
|
results
|
104
113
|
end
|
105
114
|
|
data/lib/shopee/version.rb
CHANGED