1 | # get-css [![Build Status](https://travis-ci.org/cssstats/get-css.svg?branch=master)](https://travis-ci.org/cssstats/get-css)
|
2 |
|
3 | Node module to get CSS from a URL.
|
4 |
|
5 | Returns a promise for an object with details about a document's CSS, used in <http://cssstats.com>.
|
6 |
|
7 | ## Installation
|
8 |
|
9 | ```sh
|
10 | npm i --save get-css
|
11 | ```
|
12 |
|
13 | For the CLI
|
14 |
|
15 | ```sh
|
16 | npm i -g get-css
|
17 | ```
|
18 |
|
19 | ## Usage
|
20 |
|
21 | ```js
|
22 | var getCss = require('get-css');
|
23 |
|
24 | var options = {
|
25 | timeout: 5000
|
26 | };
|
27 |
|
28 | getCss('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 | ```
|
40 | npm i -g get-css
|
41 | getcss google.com > google.css
|
42 | ```
|
43 |
|
44 | ## Response
|
45 |
|
46 | ### `links`
|
47 | An array of objects base on `rel=stylesheet` links found in the document.
|
48 |
|
49 | Each 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`
|
57 | An array of contents from `style` tags found in the document.
|
58 |
|
59 | ### `css`
|
60 | A concatenated string of all css found in links and styles
|
61 |
|
62 | ### `pageTitle`
|
63 | The contents of the `title` tag in the document.
|
64 |
|
65 | ## Options
|
66 |
|
67 | ### `timeout`
|
68 | An integer to reflect the timeout for the request. Default: `5000`
|
69 |
|
70 | ### `ignoreCerts`
|
71 | A boolean to determine whether invalid certificates are ignored. Default: `false`
|
72 |
|
73 | ### `verbose`
|
74 | A boolean to determine whether errors should be `console.log`ged. Default: `false`
|
75 |
|
76 | ## License
|
77 |
|
78 | MIT
|
79 |
|
80 | ## Contributing
|
81 |
|
82 | 1. Fork it
|
83 | 2. Create your feature branch (`git checkout -b my-new-feature`)
|
84 | 3. Commit your changes (`git commit -am 'Add some feature'`)
|
85 | 4. Push to the branch (`git push origin my-new-feature`)
|
86 | 5. Create new Pull Request
|