0.0.9 • Published 10 years ago

ecommerce-scraper v0.0.9

Weekly downloads
2
License
ISC
Repository
github
Last release
10 years ago

ecommerce-scraper

ecommerce scraper

install

npm install ecommerce-scraper

Examples

Lazada Scraper

//lazada.js
//node lazada.js

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)
		}
});

Tokopedia Scraper

// tokopedia.js
// node tokopedia.js

var engine=require('ecommerce-scraper')

engine.start({
	homepage:'http://tokopedia.com',
	getAllCategorys:function($){
			var catUrls=[]
			$('.allcat a').each(function(){
					catUrls.push($(this).attr('href'))
			})
			return catUrls
	},
		maxProcess:2,
		getMaxPages:function($){
					return 1
		},
		formatUrl:function(url,page){
					return url+'?page='+page;
		},
		getProductsUrl:function($){
					var productUrls=[]
					$('.product').each(function(){
								productUrls.push($(this).find('a').first().attr('href'))
					})
					return productUrls
		},
		fields:{
					title:function($){
								return $('.product-title').text()
					},
					price:function($){
								return $('span[itemprop=price]').first().text()
					},
					category:function($){
								return $('.breadcrumb li').eq(2).text()
					}
		},
		onComplated:function(result){
					console.log(result)
		}
});
0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago