forked from lukluk/ecommerce-scraper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lazada.js
43 lines (40 loc) · 867 Bytes
/
lazada.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var engine=require('./ecommerce-scraper')
engine.start({
homepage:'http://lazada.co.id',
getAllCategorys:function($){
var catUrls=[]
$('.sidebarSecond__itemTitle a').each(function(){
catUrls.push($(this).attr('href'))
})
return catUrls
},
maxProcess:2,
getMaxPages:function($){
//return $('.pages a').last().text();
return 1
},
formatUrl:function(url,page){
return url+'?page='+page;
},
getProductsUrl:function($){
var productUrls=[]
$('.product-card').each(function(){
productUrls.push($(this).attr('href'))
})
return productUrls
},
fields:{
title:function($){
return $('#prod_title').text()
},
brand:function($){
return $('.prod_header_brand_action a').first().text()
},
special_price:function($){
return $('#special_price_box').text()
}
},
onComplated:function(result){
console.log(result)
}
});