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 |
|
48 | An array of objects base on `rel=stylesheet` links found in the document.
|
49 |
|
50 | Each 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 |
|
59 | An array of contents from `style` tags found in the document.
|
60 |
|
61 | ### `css`
|
62 |
|
63 | A concatenated string of all css found in links and styles
|
64 |
|
65 | ### `pageTitle`
|
66 |
|
67 | The contents of the `title` tag in the document.
|
68 |
|
69 | ## Options
|
70 |
|
71 | ### `timeout`
|
72 |
|
73 | An integer to reflect the timeout for the request. Default: `5000`
|
74 |
|
75 | ### `ignoreCerts`
|
76 |
|
77 | A boolean to determine whether invalid certificates are ignored. Default: `false`
|
78 |
|
79 | ### `verbose`
|
80 |
|
81 | A boolean to determine whether errors should be `console.log`ged. Default: `false`
|
82 |
|
83 | ## License
|
84 |
|
85 | MIT
|
86 |
|
87 | ## Contributing
|
88 |
|
89 | 1. Fork it
|
90 | 2. Create your feature branch (`git checkout -b my-new-feature`)
|
91 | 3. Commit your changes (`git commit -am 'Add some feature'`)
|
92 | 4. Push to the branch (`git push origin my-new-feature`)
|
93 | 5. Create new Pull Request
|