addition of doAndroidDeveloper parser

This commit is contained in:
Martin Donnelly 2016-03-30 13:53:19 +01:00
parent 0064ddd548
commit 11d0630850

View File

@ -37,9 +37,18 @@ var generics = [
var specialHandlers = [{
url: 'www.reddit.com', fn: function (body, url) {
return doReddit(body, url);
return doReddit(body, url);
}
}];
},
{
url: 'developer.android.com', fn: function (body, url) {
return doAndroidDeveloper(body, url);
}
}
];
function cleaner(b) {
var _b = b;
@ -69,7 +78,8 @@ function cleaner(b) {
'.single-recipe-sidebar',
'#recipe-related-videos',
'#tnav',
'.footer'
'.footer',
'#tb-wrapper'
];
@ -203,6 +213,29 @@ busEmitter.on('getBookmarkRedo', doGetBookmarkRedo);
busEmitter.on('updateTagsDB', doUpdateTagsDB);
busEmitter.on('saveTagsDB', doSaveTagsDB);
function doAndroidDeveloper(body, url)
{
logger.info('GRABBING AndroidDeveloper');
var obj = {}, tdihbody, i, urlObj, urlPrefix;
var $ = cheerio.load(body);
var title = $('TITLE').text();
tdihbody = $('DIV.jd-descr');
logger.debug(tdihbody.length);
tdihbody = cleaner(tdihbody);
logger.debug(title);
obj.url = STRING(url).trim().s;
obj.html = $.html();
obj.reduced = STRING(tdihbody.html()).trim().s;
obj.nib = STRING(tdihbody.text()).collapseWhitespace().trim().left(300).s;
obj.title = STRING(title).collapseWhitespace().s;
obj.markdown = converter.convert(obj.reduced);
return obj;
}
function doReddit(body, url)