html-get 2.11.5 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +4 -4
- package/package.json +1 -1
- package/src/auto-domains.json +29 -29
- package/src/html.js +21 -8
package/bin/index.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
'use strict'
|
|
4
4
|
|
|
5
5
|
const createBrowserless = require('browserless')
|
|
6
|
-
const mri = require('mri')
|
|
7
6
|
const { URL } = require('url')
|
|
7
|
+
const mri = require('mri')
|
|
8
8
|
|
|
9
9
|
const getHTML = require('..')
|
|
10
10
|
|
|
@@ -26,9 +26,9 @@ getHTML(url, { getBrowserless, ...args })
|
|
|
26
26
|
headers: ${
|
|
27
27
|
headers
|
|
28
28
|
? Object.keys(headers).reduce(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
(acc, key) => `${acc}${key}=${headers[key]} `,
|
|
30
|
+
''
|
|
31
|
+
)
|
|
32
32
|
: '-'
|
|
33
33
|
}
|
|
34
34
|
`)
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "html-get",
|
|
3
3
|
"description": "Get the HTML from any website, using prerendering when is necessary.",
|
|
4
4
|
"homepage": "https://nicedoc.com/microlinkhq/html-get",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.12.0",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"html-get": "bin/index.js"
|
package/src/auto-domains.json
CHANGED
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
[
|
|
21
21
|
[
|
|
22
22
|
"domainWithoutSuffix",
|
|
23
|
-
"
|
|
23
|
+
"wordpress"
|
|
24
24
|
]
|
|
25
25
|
],
|
|
26
26
|
[
|
|
27
27
|
[
|
|
28
28
|
"domainWithoutSuffix",
|
|
29
|
-
"
|
|
29
|
+
"microsoft"
|
|
30
30
|
]
|
|
31
31
|
],
|
|
32
32
|
[
|
|
@@ -44,25 +44,25 @@
|
|
|
44
44
|
[
|
|
45
45
|
[
|
|
46
46
|
"domainWithoutSuffix",
|
|
47
|
-
"
|
|
47
|
+
"github"
|
|
48
48
|
]
|
|
49
49
|
],
|
|
50
50
|
[
|
|
51
51
|
[
|
|
52
52
|
"domainWithoutSuffix",
|
|
53
|
-
"
|
|
53
|
+
"vimeo"
|
|
54
54
|
]
|
|
55
55
|
],
|
|
56
56
|
[
|
|
57
57
|
[
|
|
58
58
|
"domainWithoutSuffix",
|
|
59
|
-
"
|
|
59
|
+
"slideshare"
|
|
60
60
|
]
|
|
61
61
|
],
|
|
62
62
|
[
|
|
63
63
|
[
|
|
64
64
|
"domainWithoutSuffix",
|
|
65
|
-
"
|
|
65
|
+
"imdb"
|
|
66
66
|
]
|
|
67
67
|
],
|
|
68
68
|
[
|
|
@@ -74,31 +74,31 @@
|
|
|
74
74
|
[
|
|
75
75
|
[
|
|
76
76
|
"domainWithoutSuffix",
|
|
77
|
-
"
|
|
77
|
+
"bbc"
|
|
78
78
|
]
|
|
79
79
|
],
|
|
80
80
|
[
|
|
81
81
|
[
|
|
82
82
|
"domainWithoutSuffix",
|
|
83
|
-
"
|
|
83
|
+
"theguardian"
|
|
84
84
|
]
|
|
85
85
|
],
|
|
86
86
|
[
|
|
87
87
|
[
|
|
88
88
|
"domainWithoutSuffix",
|
|
89
|
-
"
|
|
89
|
+
"telegraph"
|
|
90
90
|
]
|
|
91
91
|
],
|
|
92
92
|
[
|
|
93
93
|
[
|
|
94
94
|
"domainWithoutSuffix",
|
|
95
|
-
"
|
|
95
|
+
"pinterest"
|
|
96
96
|
]
|
|
97
97
|
],
|
|
98
98
|
[
|
|
99
99
|
[
|
|
100
100
|
"domainWithoutSuffix",
|
|
101
|
-
"
|
|
101
|
+
"huffingtonpost"
|
|
102
102
|
]
|
|
103
103
|
],
|
|
104
104
|
[
|
|
@@ -110,31 +110,31 @@
|
|
|
110
110
|
[
|
|
111
111
|
[
|
|
112
112
|
"domainWithoutSuffix",
|
|
113
|
-
"
|
|
113
|
+
"spotify"
|
|
114
114
|
]
|
|
115
115
|
],
|
|
116
116
|
[
|
|
117
117
|
[
|
|
118
118
|
"domainWithoutSuffix",
|
|
119
|
-
"
|
|
119
|
+
"eventbrite"
|
|
120
120
|
]
|
|
121
121
|
],
|
|
122
122
|
[
|
|
123
123
|
[
|
|
124
|
-
"
|
|
125
|
-
"
|
|
124
|
+
"domainWithoutSuffix",
|
|
125
|
+
"yelp"
|
|
126
126
|
]
|
|
127
127
|
],
|
|
128
128
|
[
|
|
129
129
|
[
|
|
130
130
|
"domainWithoutSuffix",
|
|
131
|
-
"
|
|
131
|
+
"engadget"
|
|
132
132
|
]
|
|
133
133
|
],
|
|
134
134
|
[
|
|
135
135
|
[
|
|
136
136
|
"domainWithoutSuffix",
|
|
137
|
-
"
|
|
137
|
+
"techcrunch"
|
|
138
138
|
]
|
|
139
139
|
],
|
|
140
140
|
[
|
|
@@ -146,25 +146,31 @@
|
|
|
146
146
|
[
|
|
147
147
|
[
|
|
148
148
|
"domainWithoutSuffix",
|
|
149
|
-
"
|
|
149
|
+
"theverge"
|
|
150
|
+
]
|
|
151
|
+
],
|
|
152
|
+
[
|
|
153
|
+
[
|
|
154
|
+
"domain",
|
|
155
|
+
"abc.net.au"
|
|
150
156
|
]
|
|
151
157
|
],
|
|
152
158
|
[
|
|
153
159
|
[
|
|
154
160
|
"domainWithoutSuffix",
|
|
155
|
-
"
|
|
161
|
+
"etsy"
|
|
156
162
|
]
|
|
157
163
|
],
|
|
158
164
|
[
|
|
159
165
|
[
|
|
160
166
|
"domainWithoutSuffix",
|
|
161
|
-
"
|
|
167
|
+
"stackoverflow"
|
|
162
168
|
]
|
|
163
169
|
],
|
|
164
170
|
[
|
|
165
171
|
[
|
|
166
172
|
"domainWithoutSuffix",
|
|
167
|
-
"
|
|
173
|
+
"flickr"
|
|
168
174
|
]
|
|
169
175
|
],
|
|
170
176
|
[
|
|
@@ -194,13 +200,13 @@
|
|
|
194
200
|
[
|
|
195
201
|
[
|
|
196
202
|
"domainWithoutSuffix",
|
|
197
|
-
"
|
|
203
|
+
"ghost"
|
|
198
204
|
]
|
|
199
205
|
],
|
|
200
206
|
[
|
|
201
207
|
[
|
|
202
208
|
"domainWithoutSuffix",
|
|
203
|
-
"
|
|
209
|
+
"giphy"
|
|
204
210
|
]
|
|
205
211
|
],
|
|
206
212
|
[
|
|
@@ -233,12 +239,6 @@
|
|
|
233
239
|
"sourceforge"
|
|
234
240
|
]
|
|
235
241
|
],
|
|
236
|
-
[
|
|
237
|
-
[
|
|
238
|
-
"domainWithoutSuffix",
|
|
239
|
-
"stackoverflow"
|
|
240
|
-
]
|
|
241
|
-
],
|
|
242
242
|
[
|
|
243
243
|
[
|
|
244
244
|
"domainWithoutSuffix",
|
package/src/html.js
CHANGED
|
@@ -22,22 +22,33 @@ const has = el => el.length !== 0
|
|
|
22
22
|
|
|
23
23
|
const upsert = (el, collection, item) => !has(el) && collection.push(item)
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Infer timestamp from `last-modified`, `date`, or `age` response headers.
|
|
27
|
+
*/
|
|
28
|
+
const getDate = headers => {
|
|
29
|
+
const timestamp = get(headers, 'last-modified') || get(headers, 'date')
|
|
30
|
+
return timestamp
|
|
31
|
+
? toDate(timestamp)
|
|
32
|
+
: toDate(Date.now() - Number(get(headers, 'age')) * 1000)
|
|
33
|
+
}
|
|
34
|
+
|
|
25
35
|
const addHead = ({ $, url, headers }) => {
|
|
26
36
|
const tags = []
|
|
27
37
|
const contentType = get(headers, 'content-type')
|
|
28
38
|
const charset = nth(split(contentType, 'charset='), 1)
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
39
|
+
const date = getDate(headers)
|
|
40
|
+
const { domain } = parseUrl(url)
|
|
32
41
|
const head = $('head')
|
|
33
42
|
|
|
34
43
|
upsert(head.find('title'), tags, `<title>${path.basename(url)}</title>`)
|
|
35
44
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
if (domain) {
|
|
46
|
+
upsert(
|
|
47
|
+
head.find('meta[property="og:site_name"]'),
|
|
48
|
+
tags,
|
|
49
|
+
`<meta property="og:site_name" content="${domain}">`
|
|
50
|
+
)
|
|
51
|
+
}
|
|
41
52
|
|
|
42
53
|
if (date) {
|
|
43
54
|
upsert(
|
|
@@ -177,3 +188,5 @@ module.exports = ({
|
|
|
177
188
|
|
|
178
189
|
return rewriteUrls ? rewriteCssUrls({ html: $.html(), url }) : $.html()
|
|
179
190
|
}
|
|
191
|
+
|
|
192
|
+
module.exports.getDate = getDate
|