@detiq/crawler 1.1.8 → 1.1.9
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/dist/accessibility-auditor.js +74 -54
- package/dist/ai-login.js +249 -227
- package/dist/auth-token-rotator.js +67 -57
- package/dist/auth.js +336 -299
- package/dist/browser-extension.js +142 -104
- package/dist/captcha-solver.js +125 -98
- package/dist/color-contrast.js +89 -77
- package/dist/content-chunker.js +126 -126
- package/dist/content-dedup.js +71 -54
- package/dist/cookie-consent.js +83 -68
- package/dist/cookie-jar.js +60 -53
- package/dist/crawler.js +5345 -4486
- package/dist/custom-js-injector.js +61 -45
- package/dist/dark-mode-capture.js +81 -67
- package/dist/dead-link-detector.js +55 -47
- package/dist/element-hash.js +12 -8
- package/dist/email-otp.js +195 -154
- package/dist/engine-router.js +98 -87
- package/dist/export/bulk-export.js +55 -70
- package/dist/export/vector-export.js +105 -77
- package/dist/extractors/advanced.js +266 -249
- package/dist/extractors/artifact-envelope.js +58 -59
- package/dist/failure-analysis-agent.js +33 -37
- package/dist/feature-flag-detector.js +66 -51
- package/dist/form-detector.js +75 -55
- package/dist/frontier.js +101 -76
- package/dist/gap-pass.js +89 -68
- package/dist/graphql-detector.js +72 -62
- package/dist/http-engine.js +330 -282
- package/dist/incremental-diff.js +87 -54
- package/dist/index.js +28 -67
- package/dist/input-fuzzer.js +97 -93
- package/dist/interactive-probe.js +827 -715
- package/dist/job-queue.js +2169 -2151
- package/dist/js-coverage.js +56 -52
- package/dist/js-router-detector.js +117 -86
- package/dist/language-detector.js +63 -51
- package/dist/link-classifier.js +50 -32
- package/dist/live-view.js +108 -91
- package/dist/locator-extractor.js +187 -151
- package/dist/logger.js +7 -9
- package/dist/markdown-extract.js +61 -48
- package/dist/native-crawler.js +946 -780
- package/dist/network-observer.js +156 -135
- package/dist/network-throttle.js +40 -29
- package/dist/openapi-generator.js +92 -77
- package/dist/pdf-extractor.js +90 -72
- package/dist/performance-metrics.js +102 -80
- package/dist/phash.js +144 -125
- package/dist/pii-scrubber.js +68 -65
- package/dist/playwright-recorder.js +58 -70
- package/dist/policies/crawl-safety.js +34 -31
- package/dist/profiles/domain-profile.js +125 -130
- package/dist/proxy.js +172 -146
- package/dist/rate-limiter.js +65 -58
- package/dist/redirect-tracker.js +64 -60
- package/dist/redis-frontier.js +136 -116
- package/dist/redis-queue.js +144 -157
- package/dist/response-cache.js +140 -127
- package/dist/responsive-detector.js +46 -42
- package/dist/retry-policy.js +50 -46
- package/dist/robots-txt.js +83 -69
- package/dist/screen-reader.js +70 -45
- package/dist/screenshot-masker.js +77 -59
- package/dist/seo-checker.js +107 -88
- package/dist/session-capture.js +212 -192
- package/dist/session-export.js +133 -107
- package/dist/sitemap-writer.js +41 -38
- package/dist/sitemap.js +202 -141
- package/dist/skyvern.js +148 -123
- package/dist/sqs-queue.js +42 -42
- package/dist/sso-token.js +90 -74
- package/dist/stealth/human-behavior.js +173 -156
- package/dist/telemetry.js +82 -68
- package/dist/test-executor.js +335 -309
- package/dist/tls-fingerprint.js +88 -77
- package/dist/url-pattern-completer.js +90 -71
- package/dist/visual-diff-verdict.js +38 -23
- package/dist/webhook-notifier.js +69 -71
- package/dist/websocket-detector.js +68 -56
- package/dist/worker.js +38 -29
- package/package.json +1 -1
package/dist/markdown-extract.js
CHANGED
|
@@ -1,54 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* HTML → Markdown extraction for crawled pages — matches crawl4AI's markdown
|
|
3
|
+
* output capability. Two-tier, mirroring crawl4AI's "markdown" vs "fit markdown":
|
|
4
|
+
*
|
|
5
|
+
* - "fit" markdown: Readability's best guess at the primary content (title +
|
|
6
|
+
* article body), stripped of nav/ads/chrome. Ideal for content/marketing
|
|
7
|
+
* pages and RAG chunking. null when Readability finds no article (most
|
|
8
|
+
* app UI screens — dashboards, forms — legitimately have none).
|
|
9
|
+
* - "full" markdown: the whole visible page converted straight to Markdown,
|
|
10
|
+
* always present. The fallback for app screens where there's no "article".
|
|
11
|
+
*
|
|
12
|
+
* Runs entirely on an already-captured `page.content()` string — no extra
|
|
13
|
+
* network fetch, no extra page navigation.
|
|
14
|
+
*/
|
|
15
|
+
import { parseHTML } from 'linkedom';
|
|
16
|
+
import { Readability } from '@mozilla/readability';
|
|
17
|
+
import TurndownService from 'turndown';
|
|
18
|
+
const turndown = new TurndownService({ headingStyle: 'atx', codeBlockStyle: 'fenced' });
|
|
19
|
+
turndown.remove(['script', 'style', 'noscript', 'svg', 'iframe']);
|
|
6
20
|
function stripNoiseElements(document) {
|
|
7
|
-
|
|
8
|
-
|
|
21
|
+
const noisy = document.querySelectorAll('script, style, noscript, svg, iframe, [aria-hidden="true"]');
|
|
22
|
+
noisy.forEach((el) => el.remove());
|
|
9
23
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const { document } = parseHTML(html);
|
|
13
|
-
stripNoiseElements(document);
|
|
14
|
-
let readabilityResult = null;
|
|
24
|
+
/** Best-effort HTML→Markdown for one crawled page. Never throws. */
|
|
25
|
+
export function extractMarkdown(html, url) {
|
|
15
26
|
try {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
const { document } = parseHTML(html);
|
|
28
|
+
stripNoiseElements(document);
|
|
29
|
+
let readabilityResult = null;
|
|
30
|
+
try {
|
|
31
|
+
// Readability mutates the DOM it's given — clone via re-parsing so the
|
|
32
|
+
// full-page fallback below still has an intact document.
|
|
33
|
+
const { document: readerDoc } = parseHTML(html);
|
|
34
|
+
stripNoiseElements(readerDoc);
|
|
35
|
+
readabilityResult = new Readability(readerDoc, { charThreshold: 50 }).parse();
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
readabilityResult = null;
|
|
39
|
+
}
|
|
40
|
+
if (readabilityResult?.content && readabilityResult.textContent.trim().length >= 50) {
|
|
41
|
+
const markdown = turndown.turndown(readabilityResult.content);
|
|
42
|
+
return {
|
|
43
|
+
markdown: `# ${readabilityResult.title || document.title || url}\n\n${markdown}`,
|
|
44
|
+
method: 'readability',
|
|
45
|
+
title: readabilityResult.title || document.title || null,
|
|
46
|
+
wordCount: readabilityResult.textContent.trim().split(/\s+/).length,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const body = document.body;
|
|
50
|
+
if (!body)
|
|
51
|
+
return null;
|
|
52
|
+
const markdown = turndown.turndown(body.innerHTML || '');
|
|
53
|
+
const text = markdown.trim();
|
|
54
|
+
if (!text)
|
|
55
|
+
return null;
|
|
56
|
+
const title = document.title || null;
|
|
57
|
+
return {
|
|
58
|
+
markdown: title ? `# ${title}\n\n${markdown}` : markdown,
|
|
59
|
+
method: 'full-page',
|
|
60
|
+
title,
|
|
61
|
+
wordCount: text.split(/\s+/).length,
|
|
62
|
+
};
|
|
21
63
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
markdown: `# ${readabilityResult.title || document.title || url}
|
|
26
|
-
|
|
27
|
-
${markdown2}`,
|
|
28
|
-
method: "readability",
|
|
29
|
-
title: readabilityResult.title || document.title || null,
|
|
30
|
-
wordCount: readabilityResult.textContent.trim().split(/\s+/).length
|
|
31
|
-
};
|
|
64
|
+
catch {
|
|
65
|
+
return null;
|
|
32
66
|
}
|
|
33
|
-
const body = document.body;
|
|
34
|
-
if (!body) return null;
|
|
35
|
-
const markdown = turndown.turndown(body.innerHTML || "");
|
|
36
|
-
const text = markdown.trim();
|
|
37
|
-
if (!text) return null;
|
|
38
|
-
const title = document.title || null;
|
|
39
|
-
return {
|
|
40
|
-
markdown: title ? `# ${title}
|
|
41
|
-
|
|
42
|
-
${markdown}` : markdown,
|
|
43
|
-
method: "full-page",
|
|
44
|
-
title,
|
|
45
|
-
wordCount: text.split(/\s+/).length
|
|
46
|
-
};
|
|
47
|
-
} catch {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
67
|
}
|
|
51
|
-
export {
|
|
52
|
-
extractMarkdown
|
|
53
|
-
};
|
|
54
|
-
//# sourceMappingURL=markdown-extract.js.map
|