making it more generic
This commit is contained in:
parent
8e46b1cdf3
commit
cbf598cbb5
@ -69,41 +69,44 @@ busEmitter.on('saveBookmarkData', doInsertBookmark);
|
||||
busEmitter.on('getBookmark', doGetBookmark);
|
||||
busEmitter.on('getBookmarkRes', doGetBookmarkRes);
|
||||
|
||||
function processBody(body,url) {
|
||||
function processBody(body, url) {
|
||||
|
||||
var $ = cheerio.load(body);
|
||||
var title = $('TITLE').text();
|
||||
var $ = cheerio.load(body);
|
||||
var title = $('TITLE').text();
|
||||
|
||||
// try to find a body to grab
|
||||
// try to find a body to grab
|
||||
|
||||
var i = 0;
|
||||
var i = 0;
|
||||
|
||||
while (($(generics[i]).length == 0) && (i < generics.length)) {
|
||||
// logger.info(generics[i]);
|
||||
// logger.info($(generics[i]));
|
||||
// logger.info('i: ' + i + ', ' + $(generics[i]).length);
|
||||
i++;
|
||||
}
|
||||
logger.debug(i);
|
||||
while (($(generics[i]).length == 0) && (i < generics.length)) {
|
||||
i++;
|
||||
}
|
||||
logger.debug(i);
|
||||
|
||||
if (i < generics.length) {
|
||||
var tdihbody = $(generics[i]);
|
||||
var obj = {};
|
||||
var tdihbody;
|
||||
var obj = {};
|
||||
if (i < generics.length) {
|
||||
tdihbody = $(generics[i]);
|
||||
logger.debug(tdihbody.length);
|
||||
tdihbody = cleaner(tdihbody);
|
||||
logger.debug(title);
|
||||
|
||||
logger.debug(tdihbody.length);
|
||||
tdihbody = cleaner(tdihbody);
|
||||
logger.debug(title);
|
||||
} else {
|
||||
// bah. nothing to reduce so just grab the body, tidy it and use that
|
||||
tdihbody = $('BODY');
|
||||
logger.debug(tdihbody.length);
|
||||
tdihbody = cleaner(tdihbody);
|
||||
logger.debug(title);
|
||||
}
|
||||
|
||||
obj.url=url;
|
||||
obj.html = $.html();
|
||||
obj.reduced = STRING(tdihbody.html()).collapseWhitespace().s;
|
||||
obj.title = STRING(title).collapseWhitespace().s;
|
||||
obj.url = url;
|
||||
obj.html = $.html();
|
||||
obj.reduced = STRING(tdihbody.html()).collapseWhitespace().s;
|
||||
obj.title = STRING(title).collapseWhitespace().s;
|
||||
|
||||
busEmitter.emit("saveBookmarkData", obj);
|
||||
|
||||
return obj;
|
||||
}
|
||||
busEmitter.emit("saveBookmarkData", obj);
|
||||
|
||||
return obj;
|
||||
|
||||
}
|
||||
function genericGrab(url,res) {
|
||||
|
Loading…
Reference in New Issue
Block a user