0.1.7 • Published 6 years ago

scrape-to-feed v0.1.7

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

scrape-to-feed

Serve feeds from scraped HTML.

Install

npm install scrape-to-feed

Usage

  1. At the root of your project, create a feeds directory. This directory will contain exported modules for defining your feeds, one feed per file.

  2. Add a feed. Here is an example, ./feeds/nyt-example-feed.js:

module.exports = {
  url: "https://www.nytimes.com/",
  handler: $ => [
    { title: "NYT example feed" },
    ...$(".story-heading")
      .toArray()
      .map(function(story) {
        const $story = $(story);
        return {
          item: {
            title: $story.text(),
            link: $story.find("a").attr("href")
          }
        };
      })
  ]
};
  1. Create and serve your feeds:
#!/usr/bin/env node
require("scrape-to-feed")();
  1. Your feed will be available at: localhost:3000/nyt-example-feed

Arguments

By default, all feeds will be re-scaped and rebuilt every hour. You can pass a custom interval, like so:

require("scrape-to-feed")(1000 * 60 * 60 * 24); // Update feeds once per day.
0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago