1 | # Get CSS
|
2 | Node module to get CSS from a URL
|
3 |
|
4 | Returns a promise for an object with details about a document's CSS
|
5 | Used in http://cssstats.com
|
6 |
|
7 | ## Usage
|
8 |
|
9 | ```js
|
10 | var getCss = require('get-css');
|
11 |
|
12 | var options = {
|
13 | timeout: 5000
|
14 | };
|
15 |
|
16 | getCss('http://github.com', options)
|
17 | .then(function(response) {
|
18 | console.log(response);
|
19 | })
|
20 | .catch(function(error) {
|
21 | console.error(error);
|
22 | });
|
23 | ```
|
24 |
|
25 | ### Using the CLI
|
26 |
|
27 | ```
|
28 | npm i -g get-css
|
29 | getcss google.com > google.css
|
30 | ```
|
31 |
|
32 | ## Response
|
33 |
|
34 | ### `links`
|
35 | An array of objects base on `rel=stylesheet` links found in the document.
|
36 |
|
37 | Each object has the following:
|
38 |
|
39 | - `link` - the value from the `href` attribute for each link tag
|
40 | - `url` - an absolute url representation of the link
|
41 | - `css` - the contents of the file in the link
|
42 | - `imports` - an array of urls for `@import` rules
|
43 |
|
44 | ### `styles`
|
45 | An array of contents from `style` tags found in the document.
|
46 |
|
47 | ### `css`
|
48 | A concatenated string of all css found in links and styles
|
49 |
|
50 | ### `pageTitle`
|
51 | The contents of the `title` tag in the document.
|
52 |
|
53 | ## Options
|
54 |
|
55 | ### `timeout`
|
56 | An integer to reflect the timeout for the request. Default: `5000`
|
57 |
|
58 | ### `ignoreCerts`
|
59 | A boolean to determine whether invalid certificates are ignored. Default: `false`
|
60 |
|
61 | ### `verbose`
|
62 | A boolean to determine whether errors should be `console.log`ged. Default: `false`
|