Socket
Socket
Sign inDemoInstall

prember-crawler

Package Overview
Dependencies
92
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    prember-crawler

A web crawler that works with prember to discover URLs in your app


Version published
Weekly downloads
3.9K
increased by26.63%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

prember-crawler

A tiny web crawler that's designed to discover URLs in your app while you are pre-rendering it with prember.

Quick Start

yarn add --dev prember-crawler or npm install --dev prember-crawler

And configure prember to use the crawler to discover URLs:

// In ember-cli-build.js
const crawl = require('prember-crawler');
let app = new EmberApp(defaults, {
  prember: {
    urls: crawl
  }
});

Customizing Behavior

The crawl method accepts the following arguments:

  • visit: the function for visiting a new URL, provided by Prember. This is required.
  • startingFrom: list of local URLs to use as starting points for the crawl. Defaults to ['/'].
  • selector: a CSS selector to use for identifying links that should be followed. Defaults to 'a'.
  • exclude: a regular expression, used for excluding specific paths from being crawled.

Putting these together, we can use crawl from within a customer URL-discovery function:

// In ember-cli-build.js
const crawl = require('prember-crawler');
let app = new EmberApp(defaults, {
  prember: {
    urls: async function({ visit }) {
      let productURLs = await crawl({ 
        visit, 
        startingFrom: ['/products'],
        selector: 'a.related-product'
        exclude: new RegExp(/^(\/app.*|\/auth.*)$/), //excludes all `/app` and `/auth` pages 
      });
      let otherURLs = ['/about', '/contact'];
      return productURLs.concat(otherURLs);
    }
  }
});

Keywords

FAQs

Last updated on 29 May 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc