Socket
Socket
Sign inDemoInstall

style-retriever

Package Overview
Dependencies
158
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    style-retriever

gets external css resources from a requested site


Version published
Maintainers
1
Created

Readme

Source

Requests a site by url, parses html into AST then retrieves link and style tags, optionally retrieving remote css resources.

const StyleRetriever = require('style-retriever');
const retriever = new StyleRetriever('https://mysite.com');
retriever
  .init()
  .then(parsed => retriever.getRemoteResources())
  .then(resources => console.log(resources))

// => [ {url: 'https://cdn.com/bootstrap.css', body: 'html{color: blue;}'}, etc... ]

You can specify some options in the configuration hash to the constructor:

  • {string} href - url of the site to scrape. If you pass a string to the constructor, this.href is set to that string.
  • {array} reducers - array of reducer functions to apply to the html AST after it has been retrieved. Defaults to two basic reducers that look for <link /> and <style> tags.
  • {object} accumulator - custom accumulator, only use this if you plan on adding custom reducers. Defaults to { linkTags: [], styleTags: [] } and isn't something you'd have to worry about in usage.

FAQs

Last updated on 08 Jun 2016

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