Skip to content

Instantly share code, notes, and snippets.

@KlonD90
Created January 16, 2014 21:51
Show Gist options
  • Save KlonD90/8464134 to your computer and use it in GitHub Desktop.
Save KlonD90/8464134 to your computer and use it in GitHub Desktop.
var cheerio = require('cheerio'),
request = require('request'),
MongoClient = require('mongodb').MongoClient;
var page = 1;
MongoClient
request('http://roxen.ru/?PAGEN_1='+page, function(err, res, body){
if(err){
console.log(err);
} else {
$ = cheerio.load(body);
var games = [];
$('#first .area_game').each(function(){
var info ={
site: 'roxen',
url: 'http://roxen.ru'+$('.pic_game a', this).attr('href'),
imageUrl: 'http://roxen.ru'+$('.pic_game img', this).attr('src'),
brands: [],
title: $('.game_title', this).text().trim(),
price: parseInt($('.price', this).text().trim(),10)
};
$('.brand img',this).each(function(){
info.brands.push($(this).attr('title').trim());
});
games.push(info);
});
console.log(games);
// console.log($('#first .pages').html());
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment