google-news-rss
Advanced tools
Comparing version 0.2.0 to 0.2.1
26
index.js
@@ -31,5 +31,26 @@ const assert = require('assert'); | ||
const deriveDescription = rawDescription => { | ||
if (!rawDescription) { | ||
return 'No description found'; | ||
} | ||
const match = rawDescription.match(/size="-1">(?!<b>).+\.\.\./g); | ||
if (match) { | ||
const description = match[0]; | ||
// decode -> striptags -> substr | ||
const formatDescription = decode(striptags(description.substr(10, description.length))); | ||
// Odd character that appears, will remove manually | ||
const removedStaryChars = formatDescription.replace(/—/g, ''); | ||
return removedStaryChars; | ||
} | ||
// Shouldn't get passed here, if so that means there have been google updates | ||
// Put will remove as much of noise as possible | ||
return decode(striptags(rawDescription)); | ||
}; | ||
const formatArticle = article => { | ||
const description = article.description; | ||
const $ = cheerio.load(description); | ||
const cleanDescription = deriveDescription(description); | ||
@@ -43,7 +64,2 @@ // Remove the appended "- Publisher" | ||
// Remove excess information in description | ||
$('font b').remove(); | ||
const htmlDescription = $.html(); | ||
const cleanDescription = decode(striptags(htmlDescription)); | ||
// Add publisher, re-formatted description, and url | ||
@@ -50,0 +66,0 @@ const formatArticle = Object.assign(article, { |
{ | ||
"name": "google-news-rss", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "A node module that searches Google News RSS Feed and returns a usable JSON response", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
11946
94