diff --git a/lib/find.js b/lib/find.js index 317c369..6150cd2 100644 --- a/lib/find.js +++ b/lib/find.js @@ -24,21 +24,29 @@ result.query = query; result.sectionHeader = $('div.section-header h3').text(); - result.result = $('ul.overview-list.badge-entry-collection > li').map(function() { + result.result = $('div.badge-entry-collection > article').map(function() { var item = { title: null, id: null, url: null, - image: null + image: null, + points: null, + commentCount: null }; - item.title = $(this).children('.info').children('h3').text().trim(); + item.title = $(this).children('header').children('a').children('h1.badge-item-title').text().trim(); item.id = $(this).attr('data-entry-id'); - item.url = "http://9gag.com" + $(this).attr('data-entry-url'); - item.image = $(this).children('.post-container').children('img').attr('src'); + + var link = $(this).children('div.post-container').children('a').attr('href'); + item.url = link.indexOf('9gag.com') === -1 ? ('http://9gag.com' + link) : link; + item.image = $(this).children('div.post-container').children('a').children('img').attr('src'); + item.points = $(this).children('p.post-meta').children('a.badge-evt.point').children('span.badge-item-love-count').text().trim(); + item.commentCount = $(this).children('p.post-meta').children('a.badge-evt.comment').text().trim(); + item.commentCount = item.commentCount.substring(0, item.commentCount.indexOf(' comments')); + return item; }).get(); return next(null, result); }); } -}()); \ No newline at end of file +}()); diff --git a/lib/section.js b/lib/section.js index 90158d9..af6d733 100644 --- a/lib/section.js +++ b/lib/section.js @@ -41,10 +41,8 @@ commentCount: null }; item.title = $(this).children('header').children('h2.badge-item-title').children('a').text().trim(); - item.id = $(this).attr('data-entry-id'); - - var link = $(this).children('div.post-container').children('a').attr('href'); - item.url = link.indexOf('9gag.com') === -1 ? ('http://9gag.com' + link) : link; + item.id = $(this).children('div.post-container').children('a').attr('data-entry-id'); + item.url = $(this).children('div.post-container').children('a').attr('href'); item.image = $(this).children('div.post-container').children('a').children('img').attr('src'); item.points = $(this).children('p.post-meta').children('a.badge-evt.point').children('span.badge-item-love-count').text().trim(); item.commentCount = $(this).children('p.post-meta').children('a.badge-evt.comment').text().trim();