How to use the rss-parser function in rss-parser

To help you get started, we’ve selected a few rss-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flysteur-dev / pager / src / Components / Feed / Feeds.js View on Github external
}

		// Loader
		this.setState({ loading: true });

		let feed = {
			_id:     rss,
			uri:     rss,
			title:   rss,
			icon:    '',
			created: (fromOPML) ? parseInt(Date.now() / 100) : 0
		};

		//Trying to fetch xml feed
		try {
			let parser = new Parser();
			let uri = `${PROXY_PATH}${rss}`;

			let info = await parser.parseURL(uri);
			if (info.title) {
				//Add feed title
				feed.title = info.title;
			}

			//Use google as favicon provider (o_O)
			if (window.fetch) {
				let base = info.link || rss;
				let icon = await fetch(`${PROXY_PATH}${FAVICON_PROVIDER}${base}`);
				await icon.arrayBuffer().then((buffer) => {
					//Read stream
					var binary     = '';
					var bytes      = [].slice.call(new Uint8Array(buffer));
github biskuitorg / biskuit / app / system / modules / dashboard / app / components / widget-feed.vue View on Github external
load() {
                const vm = this;
                this.feed = {};
                this.status = '';
                if (!this.widget.url) {
                    return;
                }

                this.status = 'loading';
                // TODO: CORS policies might block the request
                const parser = new RSSParser();
                parser.parseURL(this.widget.url)
                    .then((feed) => {
                        vm.feed = feed;
                        vm.status = 'done';
                    }, (err) => {
                        vm.status = 'error';
                    }
                );
            }
        }
github DIYgod / RSSHub-Radar / src / js / content / utils.js View on Github external
import RSSParser from 'rss-parser';
const rssParser = new RSSParser();

let pageRSS = null;
const defaultTitle =
    document.querySelector('title') &&
    document.querySelector('title').innerHTML &&
    document
        .querySelector('title')
        .innerHTML.replace(/<!\[CDATA\[(.*)]]>/, (match, p1) => p1)
        .trim();
const image = (document.querySelector('link[rel~="icon"]') && handleUrl(document.querySelector('link[rel~="icon"]').getAttribute('href'))) || document.location.origin + '/favicon.ico';

function handleUrl(url) {
    if (url.startsWith('//')) {
        url = document.location.protocol + url;
    } else if (url.startsWith('/')) {
        url = document.location.origin + url;
github flysteur-dev / pager / src / Components / Feed / Feed.js View on Github external
async componentDidMount() {
		//Attach listner
		this.onFeedChange();

		let parser = new Parser();
		let uri = `${PROXY_PATH}${this.state.uri}`;

		try {
			let feed     = await parser.parseURL(uri);
			let newItems = [];

			feed.items.forEach(item => {

				let date = item.isoDate || (item.pubDate) ? item.pubDate.replace(/CET|CEST/gi, '') : moment();
				let ts   = moment(date).unix();

				//Add only new items since feed was imported
				if (ts >= this.state.created) {
					newItems.push({
						_id:      item.guid || item.id,
						feedId:   this.state.id,
github plone / volto / src / components / manage / Tiles / Rss / View.jsx View on Github external
componentDidMount() {
    const parser = new Parser();
    if (this.props.data.url) {
      parser.parseURL(this.props.data.url, (err, feed) => {
        this.setState({
          feed,
        });
      });
    }
  }
github hello-efficiency-inc / raven-reader / src / renderer / parsers / feed.js View on Github external
import he from 'he'
import got from 'got'
import FeedParser from 'feedparser'
import RssParser from 'rss-parser'

const parser = new RssParser({
  defaultRSS: 2.0,
  headers: {
    'User-Agent': 'Raven Reader'
  }
})

/**
 * Parse feed
 * @param  string feedUrl
 * @return array
 */
export async function parseFeed (feedUrl, faviconUrl = null) {
  let feed
  const feeditem = {
    meta: '',
    posts: []
github freeCodeCamp / freeCodeCamp / api-server / server / rss / medium.js View on Github external
import Parser from 'rss-parser';
import _ from 'lodash';

const parser = new Parser();

const mediumFeed = 'https://medium.freecodecamp.org/feed';

function getExtract(str) {
  return str.slice(0, str.indexOf('</p>') + 4);
}

function addResponsiveClass(str) {
  return str.replace(/<img/g, '<img class="img-responsive"');
}

export function getMediumFeed() {
  return new Promise((resolve, reject) => {
    parser.parseURL(mediumFeed, (err, feed) => {
      if (err) {
        reject(err);
github plone / volto / src / components / manage / Tiles / Rss / Edit.jsx View on Github external
(async () => {
      const parser = new Parser();
      const myfeed = await parser.parseURL(this.state.url);
      this.setState({
        feed: myfeed,
      });
    })()
  }
github DIYgod / RSSHub-Radar / src / js / background / utils.js View on Github external
import { getRules, getRulesDate, refreshRules } from '../common/rules';
import parseDomain from 'parse-domain';
import RouteRecognizer from 'route-recognizer';
import { getConfig } from '../common/config';
let config;
let rules = {};
import RSSParser from 'rss-parser';
const rssParser = new RSSParser();

window.pageRSS = {};
window.pageRSSHub = {};
window.websiteRSSHub = {};

function schedule(time = +new Date() + config.refreshTimeout * 1000) {
    chrome.alarms.create('refreshRules', {
        when: time,
        periodInMinutes: config.refreshTimeout / 60,
    });
}

function initSchedule() {
    getRulesDate((lastDate) => {
        if (!lastDate || +new Date() - lastDate > config.refreshTimeout * 1000) {
            refreshRules();
github stefanjudis / netlify-menubar / src / incidentFeed.ts View on Github external
constructor() {
    this.parser = new Parser();
    this.currentFeed = [];
    this.previousFeed = [];
  }

rss-parser

A lightweight RSS parser, for Node and the browser

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis