blob: 9f0b5b55f72fca8aad11f0ea0e4b9f726df59ce1 (
plain)
1
|
var beers = []; $('.beer-details').each(function(i, b) { b = $(b); var beer = {}; beer['name'] = b.find('.name a').text().trim(); beer['style'] = b.find('.style').text().trim().replace('This beer is no longer being produced by the brewery', '').split(' - '); beer['abv'] = parseFloat(b.next('.details').find('.abv').text()); beer['added'] = b.next('.details').find('.date').text().trim().replace('Added ', '').split('/').map(t => parseInt(t, 10)); beer['rating'] = parseFloat(b.next('.details').find('.num').text().replace('(', '').replace(')','')); beer['ratings'] = parseInt(b.next('.details').find('.raters').text().replace(',','')); beers.push(beer); }); console.log(JSON.stringify(beers));
|