<commit_before>var request = require('request');
var cheerio = require('cheerio');

exports.getProduct = function(url, callback) {
    request(url, function(error, response, html) {
        if(!error) {
            var $ = cheerio.load(html);
            var product = {title:"", price:"", thumbnail:""};

            var details = $('.details-product');
            var mpTitle = details.children('.mp-title');
            var mpDetails = details.children('.mp-details');

            product.title = mpTitle.children('.prodTitle').children('span[itemprop=name]').text();

            product.price = $('.mp-pb-to').attr('data-partner-value');

            var mpPhotos = $('.mp-photos');
            product.thumbnail = mpPhotos.children('.carousel').children('.carousel-list').children().first().children('img[itemprop=thumbnail]').attr('data-szimg');
            if (product.thumbnail == null) {
                product.thumbnail = mpPhotos.children('.carousel').children('.carousel-list').children().first().children('img[itemprop=thumbnail]').attr('src');
            }

            callback(product, false);
        } else {
            callback({erro:"Cannot get product"}, true);
        }
    });
};<commit_msg>Small code refactoring<commit_after>'use strict';

var request = require('request'),
	cheerio = require('cheerio');

exports.getProduct = function(url, callback) {

	request(url, function(error, response, body) {

		if (!error) {

			var $ = cheerio.load(body),
				product = {},
				details = $('.details-product'),
				mpTitle = details.children('.mp-title'),
				mpPhotos = $('.mp-photos');

			product.title = mpTitle.children('.prodTitle').children('span[itemprop=name]').text();
			product.price = $('.mp-pb-to').attr('data-partner-value');
			product.thumbnail = mpPhotos.children('.carousel').children('.carousel-list').children().first().children('img[itemprop=thumbnail]').attr('data-szimg');

			if (product.thumbnail === undefined) {
				product.thumbnail = mpPhotos.children('.carousel').children('.carousel-list').children().first().children('img[itemprop=thumbnail]').attr('src');
			}

			callback(product, false);

		} else {

			callback({
				error: 'Cannot get product'
			}, true);

		}

	});

};
{'fraction_non_alphanumeric': 0.19481680071492405, 'fraction_numerical': 0.0, 'mean_word_length': 3.3057692307692306, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6209625', 'n_tokens_mistral': 701, 'n_tokens_neox': 630, 'n_words': 99}