npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hughrun/feedfinder

v1.0.13

Published

A module for finding RSS and Atom feeds from a given URL and vice-versa

Downloads

133

Readme

feedfinder

nodejs package for finding RSS and Atom feeds from a given URL and vice-versa

Reporting bugs or proposing changes
Usage
Methods
Caveats

Usage

To install:

npm install @hughrun/feedfinder

In your code:

const feedfinder = require('@hughrun/feedfinder')

feedfinder.getFeed(url)
  .then( x => {
    console.log(x)
    // returns an object
  })
  .catch( e => {
    console.error(e)
    // returns a string
  })

  feedfinder.getSite(feed)
    .then( x => {
      console.log(x)
      // returns an object
    })
    .catch( e => {
      console.error(e)
      // returns a string
    })

Methods

All feedfinder methods are Promises.

getFeed

getFeed(url) takes a full url (i.e. including protocol) and returns an object with the given url, the feed url, and the site name, or alternatively returns an error in the form of a string.

Examples:

feedfinder.getFeed('http://hughrundle.net')
/*  
returns:
    {
      url: 'https://hughrundle.net',
      feed: 'https://www.hughrundle.net/rss/',
      title: 'Information Flaneur'
    }
*/

feedfinder.getFeed('http://nla.gov.au')
//  returns error: 'No link to RSS or Atom feed found at this URL'

feedfinder.getFeed("https://www.example.com")
// returns error: 'URL cannot be found'

Note that the error message is returned as an error - so if you don't catch it, nothing is returned.

getSite

getSite(url) takes a full feed URL and returns an object with the site url, the provided feed url, and the site name, or alternatively returns an error in the form of a string.

Examples:

feedfinder.getSite('https://www.hughrundle.net/rss')
/*
Returns:'
  {
    url: 'https://www.hughrundle.net/',
    feed: 'https://www.hughrundle.net/rss',
    title: 'Information Flaneur'
  }
*/

feedfinder.getSite('https://www.hughrundle.net')
// returns: 'No RSS or Atom file found at this URL'

feedfinder.getSite("https://www.example.com/rss")
// returns error: 'URL cannot be found'

Caveats

Well-formed web pages will list their RSS/Atom feed in a <link>element in the head, however sometimes there is a feed for a page but it is not referred to in a head <link> element. In this case, feedfinder looks in the body of the page for anchor links (i.e. <a> elements) that look like they might point to feeds. If there is more than one link to a likely feed, the first one listed will be used. This is likely to be what you want, but there is only so much that can be done with poorly-structured pages so ...it might not be.

YouTube user, channel and playlist pages should all work as long as YouTube does not change the way it constructs RSS feeds - they are not listed on pages, but as the form is known, we can construct them from the ID.

Acknowledgements

Thanks to Sam Popowich and Tim Sherrat for licensing their blogs CC-BY, thus allowing me to use their homepages and feed files as examples for testing.