rss-parser
Advanced tools
Comparing version 2.1.1 to 2.1.2
59
index.js
@@ -22,28 +22,41 @@ var Entities = require("entities"); | ||
var parseRSS1 = function(xmlObj, callback) { | ||
callback("RSS 1.0 parsing not yet implemented.") | ||
} | ||
var parseRSS2 = function(xmlObj, callback) { | ||
var json = {feed: {entries: []}}; | ||
var channel = xmlObj.rss.channel[0]; | ||
if (channel['atom:link']) json.feed.feedUrl = channel['atom:link'][0].href; | ||
TOP_FIELDS.forEach(function(f) { | ||
if (channel[f]) json.feed[f] = channel[f][0]; | ||
}) | ||
var items = channel.item; | ||
(items || []).forEach(function(item) { | ||
var entry = {}; | ||
ITEM_FIELDS.forEach(function(f) { | ||
if (item[f]) entry[f] = item[f][0]; | ||
}) | ||
if (item.description) { | ||
entry.content = item.description[0]; | ||
if (typeof entry.content === 'object') { | ||
var builder = new XML2JS.Builder({headless: true}); | ||
entry.content = builder.buildObject(entry.content); | ||
} | ||
entry.contentSnippet = Entities.decode(stripHtml(entry.content)).trim(); | ||
} | ||
if (item.guid) { | ||
entry.guid = item.guid[0]._; | ||
} | ||
if (item.category) entry.categories = item.category; | ||
json.feed.entries.push(entry); | ||
}) | ||
callback(null, json); | ||
} | ||
Parser.parseString = function(xml, callback) { | ||
XML2JS.parseString(xml, function(err, result) { | ||
if (err) throw err; | ||
var json = {feed: {entries: []}}; | ||
var channel = result.rss.channel[0]; | ||
if (channel['atom:link']) json.feed.feedUrl = channel['atom:link'][0].href; | ||
TOP_FIELDS.forEach(function(f) { | ||
if (channel[f]) json.feed[f] = channel[f][0]; | ||
}) | ||
var items = channel.item; | ||
(items || []).forEach(function(item) { | ||
var entry = {}; | ||
ITEM_FIELDS.forEach(function(f) { | ||
if (item[f]) entry[f] = item[f][0]; | ||
}) | ||
if (item.description) { | ||
entry.content = item.description[0]; | ||
entry.contentSnippet = Entities.decode(stripHtml(entry.content)); | ||
} | ||
if (item.guid) { | ||
entry.guid = item.guid[0]._; | ||
} | ||
if (item.category) entry.categories = item.category; | ||
json.feed.entries.push(entry); | ||
}) | ||
callback(null, json); | ||
if (result.rss && result.rss.$.version && result.rss.$.version.indexOf('2') === 0) return parseRSS2(result, callback); | ||
else return parseRSS1(result, callback); | ||
}); | ||
@@ -50,0 +63,0 @@ } |
{ | ||
"name": "rss-parser", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -24,3 +24,3 @@ # rss-parser | ||
parser.parseURL('https://reddit.com/.rss', function(err, parsed) { | ||
parser.parseURL('https://www.reddit.com/.rss', function(err, parsed) { | ||
console.log(parsed.feed.title); | ||
@@ -37,3 +37,3 @@ parsed.feed.entries.forEach(function(entry) { | ||
<script> | ||
RSSParser.parseURL('https://reddit.com/.rss', function(err, parsed) { | ||
RSSParser.parseURL('https://www.reddit.com/.rss', function(err, parsed) { | ||
console.log(parsed.feed.title); | ||
@@ -40,0 +40,0 @@ parsed.feed.entries.forEach(function(entry) { |
@@ -9,3 +9,3 @@ { | ||
"content": "<table> <tr><td> <a href=\"https://www.reddit.com/r/funny/comments/3skxqc/the_water_is_too_deep_so_he_improvises/\"><img src=\"https://b.thumbs.redditmedia.com/z4zzFBqZ54WT-rFfKXVor4EraZtJVw7AodDvOZ7kitQ.jpg\" alt=\"The water is too deep, so he improvises\" title=\"The water is too deep, so he improvises\" /></a> </td><td> submitted by <a href=\"https://www.reddit.com/user/cakebeerandmorebeer\"> cakebeerandmorebeer </a> to <a href=\"https://www.reddit.com/r/funny/\"> funny</a> <br/> <a href=\"http://i.imgur.com/U407R75.gifv\">[link]</a> <a href=\"https://www.reddit.com/r/funny/comments/3skxqc/the_water_is_too_deep_so_he_improvises/\">[275 comments]</a> </td></tr></table>", | ||
"contentSnippet": " submitted by cakebeerandmorebeer to funny [link] [275 comments] ", | ||
"contentSnippet": "submitted by cakebeerandmorebeer to funny [link] [275 comments]", | ||
"guid": "https://www.reddit.com/r/funny/comments/3skxqc/the_water_is_too_deep_so_he_improvises/", | ||
@@ -32,3 +32,3 @@ "categories": [ | ||
"content": "<table> <tr><td> <a href=\"https://www.reddit.com/r/mildlyinteresting/comments/3sklpy/the_tapestry_above_my_bed_made_a_pretty_sweet/\"><img src=\"https://b.thumbs.redditmedia.com/tw1ncVqsrvR_pH9U8ZLz1cSiSCVGOKrch4PAc2WSIUI.jpg\" alt=\"The tapestry above my bed made a pretty sweet reflection in my coffee this morning.\" title=\"The tapestry above my bed made a pretty sweet reflection in my coffee this morning.\" /></a> </td><td> submitted by <a href=\"https://www.reddit.com/user/deathbypolkadots\"> deathbypolkadots </a> to <a href=\"https://www.reddit.com/r/mildlyinteresting/\"> mildlyinteresting</a> <br/> <a href=\"http://imgur.com/CgZzfSd\">[link]</a> <a href=\"https://www.reddit.com/r/mildlyinteresting/comments/3sklpy/the_tapestry_above_my_bed_made_a_pretty_sweet/\">[307 comments]</a> </td></tr></table>", | ||
"contentSnippet": " submitted by deathbypolkadots to mildlyinteresting [link] [307 comments] ", | ||
"contentSnippet": "submitted by deathbypolkadots to mildlyinteresting [link] [307 comments]", | ||
"guid": "https://www.reddit.com/r/mildlyinteresting/comments/3sklpy/the_tapestry_above_my_bed_made_a_pretty_sweet/", | ||
@@ -44,3 +44,3 @@ "categories": [ | ||
"content": "<table> <tr><td> <a href=\"https://www.reddit.com/r/videos/comments/3sknd4/safe_space_students_silence_asian_woman_for/\"><img src=\"https://b.thumbs.redditmedia.com/jzzjUQ9gmdXRUXp4LMS-GinAnS1gWnQap_GzvX0eH9o.jpg\" alt=\""Safe Space" Students Silence Asian Woman For Saying "Black People Can Be Racist"\" title=\""Safe Space" Students Silence Asian Woman For Saying "Black People Can Be Racist"\" /></a> </td><td> submitted by <a href=\"https://www.reddit.com/user/chouryujin\"> chouryujin </a> to <a href=\"https://www.reddit.com/r/videos/\"> videos</a> <br/> <a href=\"https://www.youtube.com/watch?v=A8UTj8lQJhY\">[link]</a> <a href=\"https://www.reddit.com/r/videos/comments/3sknd4/safe_space_students_silence_asian_woman_for/\">[5967 comments]</a> </td></tr></table>", | ||
"contentSnippet": " submitted by chouryujin to videos [link] [5967 comments] ", | ||
"contentSnippet": "submitted by chouryujin to videos [link] [5967 comments]", | ||
"guid": "https://www.reddit.com/r/videos/comments/3sknd4/safe_space_students_silence_asian_woman_for/", | ||
@@ -56,3 +56,3 @@ "categories": [ | ||
"content": "<table> <tr><td> <a href=\"https://www.reddit.com/r/pics/comments/3sk91b/kinder_surprise_tiger_repainting/\"><img src=\"https://a.thumbs.redditmedia.com/GNvH1K5SQ2imJ5hrp1707C-A015AyntDdB2y83NJr30.jpg\" alt=\"Kinder Surprise Tiger repainting\" title=\"Kinder Surprise Tiger repainting\" /></a> </td><td> submitted by <a href=\"https://www.reddit.com/user/aquamine\"> aquamine </a> to <a href=\"https://www.reddit.com/r/pics/\"> pics</a> <br/> <a href=\"http://imgur.com/gallery/8TFsT\">[link]</a> <a href=\"https://www.reddit.com/r/pics/comments/3sk91b/kinder_surprise_tiger_repainting/\">[431 comments]</a> </td></tr></table>", | ||
"contentSnippet": " submitted by aquamine to pics [link] [431 comments] ", | ||
"contentSnippet": "submitted by aquamine to pics [link] [431 comments]", | ||
"guid": "https://www.reddit.com/r/pics/comments/3sk91b/kinder_surprise_tiger_repainting/", | ||
@@ -68,3 +68,3 @@ "categories": [ | ||
"content": "<table> <tr><td> <a href=\"https://www.reddit.com/r/todayilearned/comments/3skcfk/til_that_movie_theater_popcorn_costs_more_per/\"><img src=\"https://a.thumbs.redditmedia.com/nhNifdkJkeCTu1UMXTbSclj01vSkqxqKjUSA0wkAvY8.jpg\" alt=\"TIL that movie theater popcorn costs more per ounce than filet mignon in U.S.A.\" title=\"TIL that movie theater popcorn costs more per ounce than filet mignon in U.S.A.\" /></a> </td><td> submitted by <a href=\"https://www.reddit.com/user/Cupcake-Warrior\"> Cupcake-Warrior </a> to <a href=\"https://www.reddit.com/r/todayilearned/\"> todayilearned</a> <br/> <a href=\"http://www.inquisitr.com/871573/movie-theater-popcorn-costs-more-than-fillet-mignon-report/\">[link]</a> <a href=\"https://www.reddit.com/r/todayilearned/comments/3skcfk/til_that_movie_theater_popcorn_costs_more_per/\">[1673 comments]</a> </td></tr></table>", | ||
"contentSnippet": " submitted by Cupcake-Warrior to todayilearned [link] [1673 comments] ", | ||
"contentSnippet": "submitted by Cupcake-Warrior to todayilearned [link] [1673 comments]", | ||
"guid": "https://www.reddit.com/r/todayilearned/comments/3skcfk/til_that_movie_theater_popcorn_costs_more_per/", | ||
@@ -80,3 +80,3 @@ "categories": [ | ||
"content": "<table> <tr><td> <a href=\"https://www.reddit.com/r/gaming/comments/3skclh/has_fallout_gone_too_far/\"><img src=\"https://a.thumbs.redditmedia.com/Em1D61YaPNC6BdMpj62rU5YGgcDZAau1O_35-WcCD64.jpg\" alt=\"Has fallout gone too far?\" title=\"Has fallout gone too far?\" /></a> </td><td> submitted by <a href=\"https://www.reddit.com/user/Downvote\"> Downvote </a> to <a href=\"https://www.reddit.com/r/gaming/\"> gaming</a> <br/> <a href=\"http://i.imgur.com/UXcrPDt.jpg\">[link]</a> <a href=\"https://www.reddit.com/r/gaming/comments/3skclh/has_fallout_gone_too_far/\">[713 comments]</a> </td></tr></table>", | ||
"contentSnippet": " submitted by Downvote to gaming [link] [713 comments] ", | ||
"contentSnippet": "submitted by Downvote to gaming [link] [713 comments]", | ||
"guid": "https://www.reddit.com/r/gaming/comments/3skclh/has_fallout_gone_too_far/", | ||
@@ -92,3 +92,3 @@ "categories": [ | ||
"content": "<table> <tr><td> <a href=\"https://www.reddit.com/r/gifs/comments/3sl5xh/nailed_it/\"><img src=\"https://a.thumbs.redditmedia.com/1J-fkj7K1CFJv0f_Qr5M7oPX3LeVTr920sm_9R-Zes8.jpg\" alt=\"Nailed it!\" title=\"Nailed it!\" /></a> </td><td> submitted by <a href=\"https://www.reddit.com/user/JCFC23\"> JCFC23 </a> to <a href=\"https://www.reddit.com/r/gifs/\"> gifs</a> <br/> <a href=\"http://i.imgur.com/X58Ea3Q.gifv\">[link]</a> <a href=\"https://www.reddit.com/r/gifs/comments/3sl5xh/nailed_it/\">[87 comments]</a> </td></tr></table>", | ||
"contentSnippet": " submitted by JCFC23 to gifs [link] [87 comments] ", | ||
"contentSnippet": "submitted by JCFC23 to gifs [link] [87 comments]", | ||
"guid": "https://www.reddit.com/r/gifs/comments/3sl5xh/nailed_it/", | ||
@@ -104,3 +104,3 @@ "categories": [ | ||
"content": "<table> <tr><td> <a href=\"https://www.reddit.com/r/creepy/comments/3sk919/im_sorry/\"><img src=\"https://b.thumbs.redditmedia.com/S3K29_wbPIeiClFJsIVXR9clLTZ_BtQhr-6iVlIln-w.jpg\" alt=\"I'm Sorry\" title=\"I'm Sorry\" /></a> </td><td> submitted by <a href=\"https://www.reddit.com/user/englad\"> englad </a> to <a href=\"https://www.reddit.com/r/creepy/\"> creepy</a> <br/> <a href=\"http://i.imgur.com/FfmZs.jpg\">[link]</a> <a href=\"https://www.reddit.com/r/creepy/comments/3sk919/im_sorry/\">[537 comments]</a> </td></tr></table>", | ||
"contentSnippet": " submitted by englad to creepy [link] [537 comments] ", | ||
"contentSnippet": "submitted by englad to creepy [link] [537 comments]", | ||
"guid": "https://www.reddit.com/r/creepy/comments/3sk919/im_sorry/", | ||
@@ -160,3 +160,3 @@ "categories": [ | ||
"content": "<table> <tr><td> <a href=\"https://www.reddit.com/r/movies/comments/3sjmd1/constantine_is_a_terrible_hellblazer_adaption_but/\"><img src=\"https://b.thumbs.redditmedia.com/LuK1k_r8zX6c23w9yBqfcYgGvkrnrlczc5CKPb7r3oA.jpg\" alt=\"Constantine is a Terrible Hellblazer Adaption, But a Damned Good Modern Noir\" title=\"Constantine is a Terrible Hellblazer Adaption, But a Damned Good Modern Noir\" /></a> </td><td> submitted by <a href=\"https://www.reddit.com/user/StephenKong\"> StephenKong </a> to <a href=\"https://www.reddit.com/r/movies/\"> movies</a> <br/> <a href=\"http://www.tor.com/2015/11/12/constantine-is-a-terrible-hellblazer-adaption-but-a-damned-good-modern-noir/\">[link]</a> <a href=\"https://www.reddit.com/r/movies/comments/3sjmd1/constantine_is_a_terrible_hellblazer_adaption_but/\">[1457 comments]</a> </td></tr></table>", | ||
"contentSnippet": " submitted by StephenKong to movies [link] [1457 comments] ", | ||
"contentSnippet": "submitted by StephenKong to movies [link] [1457 comments]", | ||
"guid": "https://www.reddit.com/r/movies/comments/3sjmd1/constantine_is_a_terrible_hellblazer_adaption_but/", | ||
@@ -172,3 +172,3 @@ "categories": [ | ||
"content": "<table> <tr><td> <a href=\"https://www.reddit.com/r/aww/comments/3sjmfy/trying_to_fit_in_is_hard/\"><img src=\"https://b.thumbs.redditmedia.com/o5DGo3Cv9fq2dTNCaCxMx5C8Q0ZNB3uoF8JRI__lWGc.jpg\" alt=\"Trying to fit in is hard\" title=\"Trying to fit in is hard\" /></a> </td><td> submitted by <a href=\"https://www.reddit.com/user/Lilfizz33\"> Lilfizz33 </a> to <a href=\"https://www.reddit.com/r/aww/\"> aww</a> <br/> <a href=\"http://imgur.com/saNhNEm\">[link]</a> <a href=\"https://www.reddit.com/r/aww/comments/3sjmfy/trying_to_fit_in_is_hard/\">[80 comments]</a> </td></tr></table>", | ||
"contentSnippet": " submitted by Lilfizz33 to aww [link] [80 comments] ", | ||
"contentSnippet": "submitted by Lilfizz33 to aww [link] [80 comments]", | ||
"guid": "https://www.reddit.com/r/aww/comments/3sjmfy/trying_to_fit_in_is_hard/", | ||
@@ -184,3 +184,3 @@ "categories": [ | ||
"content": "<table> <tr><td> <a href=\"https://www.reddit.com/r/food/comments/3sjg1i/tiramisu_on_a_stick/\"><img src=\"https://a.thumbs.redditmedia.com/dO0f0v8KF7ma6goG2VXqDFIFawhs06ZdE9tUSf_MT-8.jpg\" alt=\"Tiramisu on a stick\" title=\"Tiramisu on a stick\" /></a> </td><td> submitted by <a href=\"https://www.reddit.com/user/DaHitcha\"> DaHitcha </a> to <a href=\"https://www.reddit.com/r/food/\"> food</a> <br/> <a href=\"http://i.imgur.com/ZaH512E.jpg\">[link]</a> <a href=\"https://www.reddit.com/r/food/comments/3sjg1i/tiramisu_on_a_stick/\">[277 comments]</a> </td></tr></table>", | ||
"contentSnippet": " submitted by DaHitcha to food [link] [277 comments] ", | ||
"contentSnippet": "submitted by DaHitcha to food [link] [277 comments]", | ||
"guid": "https://www.reddit.com/r/food/comments/3sjg1i/tiramisu_on_a_stick/", | ||
@@ -218,3 +218,3 @@ "categories": [ | ||
"content": "<table> <tr><td> <a href=\"https://www.reddit.com/r/sports/comments/3sjgvc/this_is_called_a_specky_in_afl_and_its_legal/\"><img src=\"https://b.thumbs.redditmedia.com/Q-8q32yL8WuNPEG62sSDoZB2iTe9TBRnDMZOFQAxbMg.jpg\" alt=\"This is called a specky in AFL and it's legal\" title=\"This is called a specky in AFL and it's legal\" /></a> </td><td> submitted by <a href=\"https://www.reddit.com/user/malta-\"> malta- </a> to <a href=\"https://www.reddit.com/r/sports/\"> sports</a> <br/> <a href=\"http://www.gifbin-media.info/2015/11/feui.gif.html\">[link]</a> <a href=\"https://www.reddit.com/r/sports/comments/3sjgvc/this_is_called_a_specky_in_afl_and_its_legal/\">[967 comments]</a> </td></tr></table>", | ||
"contentSnippet": " submitted by malta- to sports [link] [967 comments] ", | ||
"contentSnippet": "submitted by malta- to sports [link] [967 comments]", | ||
"guid": "https://www.reddit.com/r/sports/comments/3sjgvc/this_is_called_a_specky_in_afl_and_its_legal/", | ||
@@ -230,3 +230,3 @@ "categories": [ | ||
"content": "<table> <tr><td> <a href=\"https://www.reddit.com/r/television/comments/3sj6s0/cable_companies_are_so_scared_of_netflix_theyve/\"><img src=\"https://a.thumbs.redditmedia.com/D3mcXaEu8mWjw672FUlHGwrQUXmWtEYe4XZ-P4pD4G8.jpg\" alt=\"Cable companies are so scared of Netflix they've actually started showing fewer ads\" title=\"Cable companies are so scared of Netflix they've actually started showing fewer ads\" /></a> </td><td> submitted by <a href=\"https://www.reddit.com/user/Dracula_in_Auschwitz\"> Dracula_in_Auschwitz </a> to <a href=\"https://www.reddit.com/r/television/\"> television</a> <br/> <a href=\"http://www.businessinsider.com/cable-companies-cut-ads-because-of-netflix-2015-11\">[link]</a> <a href=\"https://www.reddit.com/r/television/comments/3sj6s0/cable_companies_are_so_scared_of_netflix_theyve/\">[2704 comments]</a> </td></tr></table>", | ||
"contentSnippet": " submitted by Dracula_in_Auschwitz to television [link] [2704 comments] ", | ||
"contentSnippet": "submitted by Dracula_in_Auschwitz to television [link] [2704 comments]", | ||
"guid": "https://www.reddit.com/r/television/comments/3sj6s0/cable_companies_are_so_scared_of_netflix_theyve/", | ||
@@ -253,3 +253,3 @@ "categories": [ | ||
"content": "<table> <tr><td> <a href=\"https://www.reddit.com/r/photoshopbattles/comments/3sjb6s/psbattle_shia_labeouf_watching_shia_labeouf_movies/\"><img src=\"https://b.thumbs.redditmedia.com/Clo1KlcJsirvKYSDGfw7sSqTr1bi9xtVQD20KZjgOUE.jpg\" alt=\"PsBattle: Shia Labeouf watching Shia Labeouf movies\" title=\"PsBattle: Shia Labeouf watching Shia Labeouf movies\" /></a> </td><td> submitted by <a href=\"https://www.reddit.com/user/itman290\"> itman290 </a> to <a href=\"https://www.reddit.com/r/photoshopbattles/\"> photoshopbattles</a> <br/> <a href=\"http://41.media.tumblr.com/fa064385b03617a35efe5cede60bb3b6/tumblr_nxobahaz961sn6lh9o3_1280.png\">[link]</a> <a href=\"https://www.reddit.com/r/photoshopbattles/comments/3sjb6s/psbattle_shia_labeouf_watching_shia_labeouf_movies/\">[476 comments]</a> </td></tr></table>", | ||
"contentSnippet": " submitted by itman290 to photoshopbattles [link] [476 comments] ", | ||
"contentSnippet": "submitted by itman290 to photoshopbattles [link] [476 comments]", | ||
"guid": "https://www.reddit.com/r/photoshopbattles/comments/3sjb6s/psbattle_shia_labeouf_watching_shia_labeouf_movies/", | ||
@@ -265,3 +265,3 @@ "categories": [ | ||
"content": "<table> <tr><td> <a href=\"https://www.reddit.com/r/OldSchoolCool/comments/3sk1ip/gwen_stefani_1980/\"><img src=\"https://b.thumbs.redditmedia.com/QIlLz8qpmhmgK8fa8XJ-4CkcDZsyhYAyJ9qnmcWcf7A.jpg\" alt=\"Gwen Stefani (1980)\" title=\"Gwen Stefani (1980)\" /></a> </td><td> submitted by <a href=\"https://www.reddit.com/user/gonewentgo\"> gonewentgo </a> to <a href=\"https://www.reddit.com/r/OldSchoolCool/\"> OldSchoolCool</a> <br/> <a href=\"http://i.imgur.com/ev4392s.jpg\">[link]</a> <a href=\"https://www.reddit.com/r/OldSchoolCool/comments/3sk1ip/gwen_stefani_1980/\">[201 comments]</a> </td></tr></table>", | ||
"contentSnippet": " submitted by gonewentgo to OldSchoolCool [link] [201 comments] ", | ||
"contentSnippet": "submitted by gonewentgo to OldSchoolCool [link] [201 comments]", | ||
"guid": "https://www.reddit.com/r/OldSchoolCool/comments/3sk1ip/gwen_stefani_1980/", | ||
@@ -277,3 +277,3 @@ "categories": [ | ||
"content": "<table> <tr><td> <a href=\"https://www.reddit.com/r/GetMotivated/comments/3sjgv1/the_best_years_of_your_life_image/\"><img src=\"https://b.thumbs.redditmedia.com/zjf-VFjzf4juRc4yYJXff4Irih746aP-CWqfdqLe5KY.jpg\" alt=\""The best years of your life..." [Image]\" title=\""The best years of your life..." [Image]\" /></a> </td><td> submitted by <a href=\"https://www.reddit.com/user/ErikBech\"> ErikBech </a> to <a href=\"https://www.reddit.com/r/GetMotivated/\"> GetMotivated</a> <br/> <a href=\"http://imgur.com/kSCiPBy\">[link]</a> <a href=\"https://www.reddit.com/r/GetMotivated/comments/3sjgv1/the_best_years_of_your_life_image/\">[181 comments]</a> </td></tr></table>", | ||
"contentSnippet": " submitted by ErikBech to GetMotivated [link] [181 comments] ", | ||
"contentSnippet": "submitted by ErikBech to GetMotivated [link] [181 comments]", | ||
"guid": "https://www.reddit.com/r/GetMotivated/comments/3sjgv1/the_best_years_of_your_life_image/", | ||
@@ -289,3 +289,3 @@ "categories": [ | ||
"content": "<table> <tr><td> <a href=\"https://www.reddit.com/r/EarthPorn/comments/3sj16i/tranquility_in_the_woods_2765x1834_almora_india/\"><img src=\"https://b.thumbs.redditmedia.com/xYA5Mo8dPlv2tjFviv5jlRm8rNAb7XNmBvTL75TxMEk.jpg\" alt=\"Tranquility in the woods [2765x1834] Almora, India Photograph by Mayank Pant\" title=\"Tranquility in the woods [2765x1834] Almora, India Photograph by Mayank Pant\" /></a> </td><td> submitted by <a href=\"https://www.reddit.com/user/Antriton\"> Antriton </a> to <a href=\"https://www.reddit.com/r/EarthPorn/\"> EarthPorn</a> <br/> <a href=\"http://imgur.com/Xkf60OT\">[link]</a> <a href=\"https://www.reddit.com/r/EarthPorn/comments/3sj16i/tranquility_in_the_woods_2765x1834_almora_india/\">[94 comments]</a> </td></tr></table>", | ||
"contentSnippet": " submitted by Antriton to EarthPorn [link] [94 comments] ", | ||
"contentSnippet": "submitted by Antriton to EarthPorn [link] [94 comments]", | ||
"guid": "https://www.reddit.com/r/EarthPorn/comments/3sj16i/tranquility_in_the_woods_2765x1834_almora_india/", | ||
@@ -292,0 +292,0 @@ "categories": [ |
@@ -7,2 +7,5 @@ var FS = require('fs'); | ||
var IN_DIR = __dirname + '/input'; | ||
var OUT_DIR = __dirname + '/output'; | ||
var INPUT_FILE = __dirname + '/input/reddit.rss'; | ||
@@ -12,9 +15,9 @@ var OUTPUT_FILE = __dirname + '/output/reddit.json'; | ||
describe('Parser', function() { | ||
it('should parse Reddit', function(done) { | ||
Parser.parseFile(INPUT_FILE, function(err, parsed) { | ||
var testParseForFile = function(name, done) { | ||
Parser.parseFile(IN_DIR + '/' + name + '.rss', function(err, parsed) { | ||
Expect(err).to.equal(null); | ||
if (process.env.WRITE_GOLDEN) { | ||
FS.writeFileSync(OUTPUT_FILE, JSON.stringify(parsed, null, 2)); | ||
FS.writeFileSync(OUT_DIR + '/' + name + '.json', JSON.stringify(parsed, null, 2)); | ||
} else { | ||
var expected = FS.readFileSync(OUTPUT_FILE, 'utf8') | ||
var expected = FS.readFileSync(OUT_DIR + '/' + name + '.json', 'utf8') | ||
expected = JSON.parse(expected); | ||
@@ -25,3 +28,18 @@ Expect(parsed).to.deep.equal(expected); | ||
}) | ||
} | ||
it('should parse Reddit', function(done) { | ||
testParseForFile('reddit', done); | ||
}) | ||
it('should parse craigslist', function(done) { | ||
Parser.parseURL('https://seattle.craigslist.org/search/act?format=rss', function(err, parsed) { | ||
Expect(err).to.not.equal(null); | ||
done(); | ||
}) | ||
}) | ||
it('should parse atom', function(done) { | ||
testParseForFile('reddit-atom', done); | ||
}) | ||
}) |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
633304
13
13498
5