html-get 2.11.4 → 2.11.6
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/package.json +5 -3
- package/src/auto-domains.json +27 -27
- package/src/html.js +8 -6
- package/src/index.js +29 -20
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.11.
|
|
5
|
+
"version": "2.11.6",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"html-get": "bin/index.js"
|
|
@@ -98,7 +98,8 @@
|
|
|
98
98
|
"test/**/*.js",
|
|
99
99
|
"!test/util.js"
|
|
100
100
|
],
|
|
101
|
-
"timeout": "2m"
|
|
101
|
+
"timeout": "2m",
|
|
102
|
+
"workerThreads": false
|
|
102
103
|
},
|
|
103
104
|
"commitlint": {
|
|
104
105
|
"extends": [
|
|
@@ -107,7 +108,8 @@
|
|
|
107
108
|
},
|
|
108
109
|
"nano-staged": {
|
|
109
110
|
"*.js": [
|
|
110
|
-
"prettier-standard"
|
|
111
|
+
"prettier-standard",
|
|
112
|
+
"standard --fix"
|
|
111
113
|
],
|
|
112
114
|
"*.md": [
|
|
113
115
|
"standard-markdown"
|
package/src/auto-domains.json
CHANGED
|
@@ -2,37 +2,37 @@
|
|
|
2
2
|
[
|
|
3
3
|
[
|
|
4
4
|
"domainWithoutSuffix",
|
|
5
|
-
"
|
|
5
|
+
"youtube"
|
|
6
6
|
]
|
|
7
7
|
],
|
|
8
8
|
[
|
|
9
9
|
[
|
|
10
10
|
"domainWithoutSuffix",
|
|
11
|
-
"
|
|
11
|
+
"google"
|
|
12
12
|
]
|
|
13
13
|
],
|
|
14
14
|
[
|
|
15
15
|
[
|
|
16
16
|
"domainWithoutSuffix",
|
|
17
|
-
"
|
|
17
|
+
"wordpress"
|
|
18
18
|
]
|
|
19
19
|
],
|
|
20
20
|
[
|
|
21
21
|
[
|
|
22
22
|
"domainWithoutSuffix",
|
|
23
|
-
"
|
|
23
|
+
"apple"
|
|
24
24
|
]
|
|
25
25
|
],
|
|
26
26
|
[
|
|
27
27
|
[
|
|
28
28
|
"domainWithoutSuffix",
|
|
29
|
-
"
|
|
29
|
+
"wikipedia"
|
|
30
30
|
]
|
|
31
31
|
],
|
|
32
32
|
[
|
|
33
33
|
[
|
|
34
34
|
"domainWithoutSuffix",
|
|
35
|
-
"
|
|
35
|
+
"microsoft"
|
|
36
36
|
]
|
|
37
37
|
],
|
|
38
38
|
[
|
|
@@ -44,85 +44,85 @@
|
|
|
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
|
+
"nytimes"
|
|
60
60
|
]
|
|
61
61
|
],
|
|
62
62
|
[
|
|
63
63
|
[
|
|
64
64
|
"domainWithoutSuffix",
|
|
65
|
-
"
|
|
65
|
+
"imdb"
|
|
66
66
|
]
|
|
67
67
|
],
|
|
68
68
|
[
|
|
69
69
|
[
|
|
70
70
|
"domainWithoutSuffix",
|
|
71
|
-
"
|
|
71
|
+
"theguardian"
|
|
72
72
|
]
|
|
73
73
|
],
|
|
74
74
|
[
|
|
75
75
|
[
|
|
76
76
|
"domainWithoutSuffix",
|
|
77
|
-
"
|
|
77
|
+
"bbc"
|
|
78
78
|
]
|
|
79
79
|
],
|
|
80
80
|
[
|
|
81
81
|
[
|
|
82
82
|
"domainWithoutSuffix",
|
|
83
|
-
"
|
|
83
|
+
"slideshare"
|
|
84
84
|
]
|
|
85
85
|
],
|
|
86
86
|
[
|
|
87
87
|
[
|
|
88
88
|
"domainWithoutSuffix",
|
|
89
|
-
"
|
|
89
|
+
"soundcloud"
|
|
90
90
|
]
|
|
91
91
|
],
|
|
92
92
|
[
|
|
93
93
|
[
|
|
94
94
|
"domainWithoutSuffix",
|
|
95
|
-
"
|
|
95
|
+
"huffingtonpost"
|
|
96
96
|
]
|
|
97
97
|
],
|
|
98
98
|
[
|
|
99
99
|
[
|
|
100
100
|
"domainWithoutSuffix",
|
|
101
|
-
"
|
|
101
|
+
"pinterest"
|
|
102
102
|
]
|
|
103
103
|
],
|
|
104
104
|
[
|
|
105
105
|
[
|
|
106
106
|
"domainWithoutSuffix",
|
|
107
|
-
"
|
|
107
|
+
"telegraph"
|
|
108
108
|
]
|
|
109
109
|
],
|
|
110
110
|
[
|
|
111
111
|
[
|
|
112
112
|
"domainWithoutSuffix",
|
|
113
|
-
"
|
|
113
|
+
"spotify"
|
|
114
114
|
]
|
|
115
115
|
],
|
|
116
116
|
[
|
|
117
117
|
[
|
|
118
118
|
"domainWithoutSuffix",
|
|
119
|
-
"
|
|
119
|
+
"techcrunch"
|
|
120
120
|
]
|
|
121
121
|
],
|
|
122
122
|
[
|
|
123
123
|
[
|
|
124
|
-
"
|
|
125
|
-
"
|
|
124
|
+
"domainWithoutSuffix",
|
|
125
|
+
"zoom"
|
|
126
126
|
]
|
|
127
127
|
],
|
|
128
128
|
[
|
|
@@ -133,20 +133,20 @@
|
|
|
133
133
|
],
|
|
134
134
|
[
|
|
135
135
|
[
|
|
136
|
-
"
|
|
137
|
-
"
|
|
136
|
+
"domain",
|
|
137
|
+
"abc.net.au"
|
|
138
138
|
]
|
|
139
139
|
],
|
|
140
140
|
[
|
|
141
141
|
[
|
|
142
142
|
"domainWithoutSuffix",
|
|
143
|
-
"
|
|
143
|
+
"eventbrite"
|
|
144
144
|
]
|
|
145
145
|
],
|
|
146
146
|
[
|
|
147
147
|
[
|
|
148
148
|
"domainWithoutSuffix",
|
|
149
|
-
"
|
|
149
|
+
"engadget"
|
|
150
150
|
]
|
|
151
151
|
],
|
|
152
152
|
[
|
|
@@ -164,7 +164,7 @@
|
|
|
164
164
|
[
|
|
165
165
|
[
|
|
166
166
|
"domainWithoutSuffix",
|
|
167
|
-
"
|
|
167
|
+
"dribbble"
|
|
168
168
|
]
|
|
169
169
|
],
|
|
170
170
|
[
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
[
|
|
189
189
|
[
|
|
190
190
|
"domainWithoutSuffix",
|
|
191
|
-
"
|
|
191
|
+
"etsy"
|
|
192
192
|
]
|
|
193
193
|
],
|
|
194
194
|
[
|
package/src/html.js
CHANGED
|
@@ -28,16 +28,18 @@ const addHead = ({ $, url, headers }) => {
|
|
|
28
28
|
const charset = nth(split(contentType, 'charset='), 1)
|
|
29
29
|
const timestamp = get(headers, 'last-modified') || get(headers, 'date')
|
|
30
30
|
const date = timestamp && toDate(timestamp)
|
|
31
|
-
|
|
31
|
+
const { domain } = parseUrl(url)
|
|
32
32
|
const head = $('head')
|
|
33
33
|
|
|
34
34
|
upsert(head.find('title'), tags, `<title>${path.basename(url)}</title>`)
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
if (domain) {
|
|
37
|
+
upsert(
|
|
38
|
+
head.find('meta[property="og:site_name"]'),
|
|
39
|
+
tags,
|
|
40
|
+
`<meta property="og:site_name" content="${domain}">`
|
|
41
|
+
)
|
|
42
|
+
}
|
|
41
43
|
|
|
42
44
|
if (date) {
|
|
43
45
|
upsert(
|
package/src/index.js
CHANGED
|
@@ -152,24 +152,32 @@ const determinateMode = (url, { prerender }) => {
|
|
|
152
152
|
return isFetchMode(url) ? 'fetch' : 'prerender'
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
const getContent =
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
155
|
+
const getContent = PCancelable.fn(
|
|
156
|
+
(
|
|
157
|
+
url,
|
|
158
|
+
mode,
|
|
159
|
+
{ getBrowserless, gotOpts, headers, puppeteerOpts, rewriteUrls, toEncode },
|
|
160
|
+
onCancel
|
|
161
|
+
) => {
|
|
162
|
+
const isFetchMode = mode === 'fetch'
|
|
163
|
+
const fetchOpts = isFetchMode
|
|
164
|
+
? { headers, toEncode, ...gotOpts }
|
|
165
|
+
: { headers, toEncode, getBrowserless, gotOpts, ...puppeteerOpts }
|
|
166
|
+
|
|
167
|
+
const promise = modes[mode](url, fetchOpts)
|
|
168
|
+
onCancel(() => promise.cancel())
|
|
169
|
+
|
|
170
|
+
return promise.then(content => {
|
|
171
|
+
const html = addHtml({
|
|
172
|
+
...content,
|
|
173
|
+
...(isFetchMode ? puppeteerOpts : undefined),
|
|
174
|
+
rewriteUrls
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
return { ...content, html }
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
)
|
|
173
181
|
|
|
174
182
|
module.exports = PCancelable.fn(
|
|
175
183
|
async (
|
|
@@ -206,14 +214,15 @@ module.exports = PCancelable.fn(
|
|
|
206
214
|
toEncode
|
|
207
215
|
})
|
|
208
216
|
|
|
209
|
-
onCancel(() => promise.
|
|
217
|
+
onCancel(() => promise.cancel())
|
|
210
218
|
|
|
211
219
|
const { mode, ...payload } = await promise
|
|
212
220
|
|
|
213
|
-
return
|
|
221
|
+
return Object.assign(payload, { stats: { mode, timing: time.rounded() } })
|
|
214
222
|
}
|
|
215
223
|
)
|
|
216
224
|
|
|
217
225
|
module.exports.REQ_TIMEOUT = REQ_TIMEOUT
|
|
218
226
|
module.exports.ABORT_TYPES = ABORT_TYPES
|
|
219
227
|
module.exports.isFetchMode = isFetchMode
|
|
228
|
+
module.exports.getContent = getContent
|