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`
47
48An array of objects base on `rel=stylesheet` links found in the document.
49
50Each object has the following:
51
52- `link` - the value from the `href` attribute for each link tag
53- `url` - an absolute url representation of the link
54- `css` - the contents of the file in the link
55- `imports` - an array of urls for `@import` rules
56
57### `styles`
58
59An array of contents from `style` tags found in the document.
60
61### `css`
62
63A concatenated string of all css found in links and styles
64
65### `pageTitle`
66
67The contents of the `title` tag in the document.
68
69## Options
70
71### `timeout`
72
73An integer to reflect the timeout for the request. Default: `5000`
74
75### `ignoreCerts`
76
77A boolean to determine whether invalid certificates are ignored. Default: `false`
78
79### `verbose`
80
81A boolean to determine whether errors should be `console.log`ged. Default: `false`
82
83## License
84
85MIT
86
87## Contributing
88
891. Fork it
902. Create your feature branch (`git checkout -b my-new-feature`)
913. Commit your changes (`git commit -am 'Add some feature'`)
924. Push to the branch (`git push origin my-new-feature`)
935. Create new Pull Request