Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

get-rss-atom

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-rss-atom - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

test.js

156

get.js
'use strict';
let hostURL = '';
exports.getRssAtom = function(feedUrl) {
if (process.argv.indexOf("-url") !== -1) {
hostURL = process.argv[process.argv.indexOf("-url") + 1]
}
const
url = require('url'),
feed = url.parse(feedUrl),
http = require('http'),
https = require('https'),
options = {
host: feed.hostname,
port: feed.port,
path: feed.path
};
const
url = require('url'),
feed = url.parse(hostURL),
http = require('http'),
https = require('https'),
options = {
host: feed.hostname,
port: feed.port,
path: feed.path
};
function getItem(content, tag) {
let tagStart = 0, tagEnd = 0, s = '', count = 0;
while (content.search('<' + tag) > 0 && count < content.length) {
tagStart = content.search('<' + tag);
tagEnd = content.search('/' + tag + '>');
if (tagEnd > tagStart) {
s = content.substr(tagStart, tagEnd - tagStart + tag.length + 2);
content = content.replace(s, '')
} else {
count++
}
}
return s.replace("<![CDATA[", "")
.replace("]]>", "")
.replace(/<[^>]+>/g, '')
.replace(/\r?\n|\r/g, '')
}
function getItem(content, tag) {
let tagStart = 0, tagEnd = 0, s = '', count = 0;
while (content.search('<' + tag) > 0 && count < content.length) {
tagStart = content.search('<' + tag);
tagEnd = content.search('/' + tag + '>');
if (tagEnd > tagStart) {
s = content.substr(tagStart, tagEnd - tagStart + tag.length + 2);
content = content.replace(s, '')
function getItemAtom(content, tag) {
const match = content.match('<' + tag + '(.*)?/>');
if (match !== null) {
return match[0].match(/"(.*)"/)[0].replace(/"/g, '')
} else {
count++
return ''
}
}
return s.replace("<![CDATA[", "")
.replace("]]>", "")
.replace(/<[^>]+>/g, '')
.replace(/\r?\n|\r/g, '')
}
function getItemAtom(content, tag) {
const match = content.match('<' + tag + '(.*)?/>');
if (match !== null) {
return match[0].match(/"(.*)"/)[0].replace(/"/g, '')
} else {
return ''
function getItems(content, tag) {
let arr = [], tagStart = 0, tagEnd = 0, count = 0;
while (content.search('<' + tag) > 0 && count < content.length) {
tagStart = content.search('<' + tag);
tagEnd = content.search('/' + tag + '>');
if (tagEnd > tagStart) {
let
s = content.substr(tagStart, tagEnd - tagStart + tag.length + 2),
t = getItem(s, 'title'),
c = getItem(s, 'content').concat(getItem(s, 'description')),
l = getItem(s, 'link');
if (t === '') t = '[Failed]';
if (c === '') c = '[Failed]';
if (l === '') l = getItemAtom(s, 'link');
if (l === '') l = '[Failed]';
arr.push({title: t, description: c, href: l});
content = content.replace(s, '')
}
count++
}
return arr
}
}
function getItems(content, tag) {
let arr = [], tagStart = 0, tagEnd = 0, count = 0;
while (content.search('<' + tag) > 0 && count < content.length) {
tagStart = content.search('<' + tag);
tagEnd = content.search('/' + tag + '>');
if (tagEnd > tagStart) {
let
s = content.substr(tagStart, tagEnd - tagStart + tag.length + 2),
t = getItem(s, 'title'),
c = getItem(s, 'content').concat(getItem(s, 'description')),
l = getItem(s, 'link');
if (t === '') t = '[Failed]';
if (c === '') c = '[Failed]';
if (l === '') l = getItemAtom(s, 'link');
if (l === '') l = '[Failed]';
arr.push( { title: t, description: c, href: l } );
content = content.replace(s, '')
}
count++
function extractItems(content) {
return getItems(content.toString(), 'item')
.concat(getItems(content.toString(), 'entry'))
}
return arr
}
function extractItems(content) {
return getItems(content.toString(), 'item')
.concat(getItems(content.toString(), 'entry'))
}
const parser = function (res) {
let content = '', count = 0;
res.on('data', chunk => content += chunk);
res.on('end', () => {
extractItems(content).forEach((item) => {
count++;
console.log(`\n--${count}-- ${item.title}\n${item.description}\n${item.href}\n`)
})
});
console.log(`Got response: ${res.statusCode}`)
};
const parser = function(res) {
let content = '', count = 0;
res.on('data', chunk => content += chunk);
res.on('end', () => {
extractItems(content).forEach((item) => {
count++;
console.log(`\n--${count}-- ${item.title}\n${item.description}\n${item.href}\n`)
if (feed.port === '80') {
http.get(options, parser).on('error', e => {
console.error(e.message)
})
});
console.log(`Got response: ${res.statusCode}`)
} else {
https.get(options, parser).on('error', e => {
console.error(e.message)
})
}
};
if (feed.port === '80') {
http.get(options, parser).on('error', e => {
console.error(e.message)
})
} else {
https.get(options, parser).on('error', e => {
console.error(e.message)
})
}
{
"name": "get-rss-atom",
"version": "1.0.0",
"description": "",
"version": "1.0.1",
"description": "Get RSS from URL and return JSON (not ready yet)",
"main": "get.js",

@@ -9,5 +9,5 @@ "scripts": {

},
"author": "",
"author": "Niels Koster",
"license": "ISC",
"dependencies": {}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc