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

prember-crawler

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

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

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.3K
increased by0.62%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 29 May 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc