UNPKG

1.79 kBMarkdownView Raw
1# get-css [![Build Status](https://travis-ci.org/cssstats/get-css.svg?branch=master)](https://travis-ci.org/cssstats/get-css)
2
3Node module to get CSS from a URL.
4
5Returns a promise for an object with details about a document's CSS, used in <http://cssstats.com>.
6
7## Installation
8
9```sh
10npm i --save get-css
11```
12
13For the CLI
14
15```sh
16npm i -g get-css
17```
18
19## Usage
20
21```js
22var getCss = require('get-css');
23
24var options = {
25 timeout: 5000
26};
27
28getCss('http://github.com', options)
29 .then(function(response) {
30 console.log(response);
31 })
32 .catch(function(error) {
33 console.error(error);
34 });
35```
36
37### Using the CLI
38
39```
40npm i -g get-css
41getcss google.com > google.css
42```
43
44## Response
45
46### `links`
47An array of objects base on `rel=stylesheet` links found in the document.
48
49Each object has the following:
50
51- `link` - the value from the `href` attribute for each link tag
52- `url` - an absolute url representation of the link
53- `css` - the contents of the file in the link
54- `imports` - an array of urls for `@import` rules
55
56### `styles`
57An array of contents from `style` tags found in the document.
58
59### `css`
60A concatenated string of all css found in links and styles
61
62### `pageTitle`
63The contents of the `title` tag in the document.
64
65## Options
66
67### `timeout`
68An integer to reflect the timeout for the request. Default: `5000`
69
70### `ignoreCerts`
71A boolean to determine whether invalid certificates are ignored. Default: `false`
72
73### `verbose`
74A boolean to determine whether errors should be `console.log`ged. Default: `false`
75
76## License
77
78MIT
79
80## Contributing
81
821. Fork it
832. Create your feature branch (`git checkout -b my-new-feature`)
843. Commit your changes (`git commit -am 'Add some feature'`)
854. Push to the branch (`git push origin my-new-feature`)
865. Create new Pull Request