html-get 2.23.0 → 2.24.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/package.json +1 -1
- package/src/index.js +23 -1
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "html-get",
|
|
3
3
|
"description": "Get the HTML from any website, fine-tuned for correction & speed",
|
|
4
4
|
"homepage": "https://nicedoc.com/microlinkhq/html-get",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.24.0",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"bin": {
|
package/src/index.js
CHANGED
|
@@ -192,6 +192,11 @@ const prerender = PCancelable.fn(
|
|
|
192
192
|
|
|
193
193
|
const modes = { fetch, prerender }
|
|
194
194
|
|
|
195
|
+
const hasShadowDOM = $ =>
|
|
196
|
+
$('*')
|
|
197
|
+
.toArray()
|
|
198
|
+
.some(el => el.tagName?.includes('-'))
|
|
199
|
+
|
|
195
200
|
const isFetchMode = url => {
|
|
196
201
|
const parsedUrl = parseUrl(url)
|
|
197
202
|
return autoDomains.some(conditions =>
|
|
@@ -309,7 +314,24 @@ module.exports = PCancelable.fn(
|
|
|
309
314
|
|
|
310
315
|
onCancel(() => promise.cancel())
|
|
311
316
|
|
|
312
|
-
|
|
317
|
+
let { mode, html, $, ...payload } = await promise
|
|
318
|
+
|
|
319
|
+
if (mode === 'fetch' && getBrowserless && hasShadowDOM($)) {
|
|
320
|
+
debug('shadow DOM detected, retrying with prerender', { url: targetUrl })
|
|
321
|
+
const prerenderPromise = getContent(targetUrl, 'prerender', {
|
|
322
|
+
getBrowserless,
|
|
323
|
+
getTemporalFile,
|
|
324
|
+
gotOpts,
|
|
325
|
+
headers,
|
|
326
|
+
mutool,
|
|
327
|
+
puppeteerOpts,
|
|
328
|
+
rewriteUrls,
|
|
329
|
+
rewriteHtml,
|
|
330
|
+
toEncode
|
|
331
|
+
})
|
|
332
|
+
onCancel(() => prerenderPromise.cancel())
|
|
333
|
+
;({ mode, html, $, ...payload } = await prerenderPromise)
|
|
334
|
+
}
|
|
313
335
|
|
|
314
336
|
return Object.assign(payload, {
|
|
315
337
|
...serializeHtml($),
|