added engadget processor
This commit is contained in:
parent
a626b34f8c
commit
b0d9b4896a
2222
app/engadget.html
Normal file
2222
app/engadget.html
Normal file
File diff suppressed because it is too large
Load Diff
@ -44,7 +44,15 @@ var specialHandlers = [{
|
||||
url: 'developer.android.com', fn: function (body, url) {
|
||||
return doAndroidDeveloper(body, url);
|
||||
}
|
||||
},
|
||||
{
|
||||
url: 'www.engadget.com', fn: function (body, url) {
|
||||
return doEngadget(body, url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
];
|
||||
|
||||
@ -213,6 +221,59 @@ busEmitter.on('getBookmarkRedo', doGetBookmarkRedo);
|
||||
busEmitter.on('updateTagsDB', doUpdateTagsDB);
|
||||
busEmitter.on('saveTagsDB', doSaveTagsDB);
|
||||
|
||||
function doEngadget(body, url)
|
||||
{
|
||||
logger.info('GRABBING Engadget');
|
||||
var obj = {}, tdihbody, i, urlObj, urlPrefix;
|
||||
|
||||
var $ = cheerio.load(body);
|
||||
var title = $('TITLE').text();
|
||||
|
||||
tdihbody = $('DIV#page_body');
|
||||
|
||||
logger.debug('Length:' , tdihbody.length);
|
||||
tdihbody = cleaner(tdihbody);
|
||||
logger.debug('Title: ', title);
|
||||
|
||||
urlObj = URL.parse(url);
|
||||
urlPrefix = urlObj.protocol + '//' + urlObj.host + '/';
|
||||
|
||||
try {
|
||||
tdihbody.find('IMG').each(function (i, elem) {
|
||||
let s, src = $(this).attr("src");
|
||||
|
||||
if (src !== null) {
|
||||
if (!STRING(src).startsWith('http')) {
|
||||
logger.debug('Stripping:' + src);
|
||||
src = urlPrefix + STRING(src).stripLeft('/').trim().s;
|
||||
}
|
||||
|
||||
if (typeof obj.thumbnail === 'undefined') {
|
||||
obj.thumbnail = src;
|
||||
}
|
||||
|
||||
s = 'http://image.silvrtree.co.uk/900,fit/' + src;
|
||||
|
||||
$(this).attr("src", s);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
logger.error(e);
|
||||
}
|
||||
|
||||
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 doAndroidDeveloper(body, url)
|
||||
{
|
||||
logger.info('GRABBING AndroidDeveloper');
|
||||
@ -346,7 +407,8 @@ function genericProcessor(body, url) {
|
||||
tdihbody.find('IMG').each(function (i, elem) {
|
||||
let s, src = $(this).attr("src");
|
||||
|
||||
if (src !== null) {
|
||||
console.log('!!!!' + src);
|
||||
if (src !== null && typeof src !== 'undefined') {
|
||||
if (!STRING(src).startsWith('http')) {
|
||||
logger.debug('Stripping:' + src);
|
||||
src = urlPrefix + STRING(src).stripLeft('/').trim().s;
|
||||
|
@ -0,0 +1,21 @@
|
||||
var generics = [
|
||||
'ARTICLE',
|
||||
'div.content_column',
|
||||
'div.post',
|
||||
'div.page',
|
||||
'#recipe-single',
|
||||
'div.content.body'
|
||||
];
|
||||
|
||||
var specialHandlers = [{
|
||||
url: 'www.reddit.com', fn: function (body, url) {
|
||||
return doReddit(body, url);
|
||||
}
|
||||
},
|
||||
{
|
||||
url: 'developer.android.com', fn: function (body, url) {
|
||||
return doAndroidDeveloper(body, url);
|
||||
}
|
||||
}
|
||||
|
||||
];
|
Loading…
Reference in New Issue
Block a user