Spinning up headless Chromium just to see whether a prospect uses HubSpot, Stripe, or Next.js and grab a public contact email is slow and expensive. Each browser context burns hundreds of megabytes of RAM and takes several seconds per domain. When we moved our enrichment worker to plain fetch() in Node 22 with a 1.5 MB stream cap, checking apify.com, stripe.com, and polar.sh finished in 211ms to 341ms per domain (including secondary page probes) using zero browser processes and zero proxies.
Raw HTML and HTTP headers still come with sharp edges: unbounded responses, Cloudflare email obfuscation, false-positive regexes, and SPA catch-all routes that return 200 OK for every path.
Cap response streams before res.text() blows memory
Calling await response.text() on arbitrary external URLs will eventually hang a batch worker. Some marketing homepages inline megabytes of base64 SVGs or JSON hydration payloads, and a misconfigured link occasionally returns an uncompressed video or PDF.
Reading the body through response.body.getReader() lets you decode UTF-8 incrementally and cancel the underlying TCP stream once you hit a byte limit:
async function readTextCapped(response, maxBytes = 1_500_000) {
if (!response.body) return '';
const reader = response.body.getReader();
const decoder = new TextDecoder('utf-8', { fatal: false });
let totalBytes = 0;
let result = '';
try {
while (true) {
const { done, value } = await reader.read();
if (done) break;
totalBytes += value.byteLength;
if (totalBytes > maxBytes) {
const overflow = totalBytes - maxBytes;
const slice = value.subarray(0, Math.max(0, value.byteLength - overflow));
result += decoder.decode(slice, { stream: false });
await reader.cancel();
break;
}
result += decoder.decode(value, { stream: true });
}
result += decoder.decode();
} catch {
// Keep whatever partial HTML arrived before stream truncation
}
return result;
}
Most script tags, meta tags, and JSON-LD blocks sit well inside the first 1.5 MB of an HTML document. For secondary /contact or /about pages where we only look for emails, we tighten the cap to 250 KB.
Decoding Cloudflare data-cfemail in 14 lines
A large share of B2B websites sit behind Cloudflare with Email Address Obfuscation turned on. When you fetch raw HTML without executing Cloudflare's client script, every email turns into one of two forms:
<span class="__cf_email__" data-cfemail="2a594b464f596a4b49474f044f524b475a464f">[email protected]</span>
<a href="/cdn-cgi/l/email-protection#2a594b464f596a4b49474f044f524b475a464f">Email us</a>
The hex string is simple XOR encoding. The first byte (two hex characters) is the key, and each subsequent byte is XORed with that key to recover the ASCII character:
export function decodeCfEmail(hex) {
if (typeof hex !== 'string') return null;
const cleaned = hex.trim();
if (cleaned.length < 6 || cleaned.length % 2 !== 0 || !/^[0-9a-fA-F]+$/.test(cleaned)) {
return null;
}
const key = parseInt(cleaned.slice(0, 2), 16);
let out = '';
for (let i = 2; i < cleaned.length; i += 2) {
const code = parseInt(cleaned.slice(i, i + 2), 16) ^ key;
if (code < 32 || code > 126) return null;
out += String.fromCharCode(code);
}
return out.trim() || null;
}
// Example: decodeCfEmail('2a594b464f596a4b49474f044f524b475a464f')
// => 'sales@acme.example'
Checking code < 32 || code > 126 rejects corrupted or non-email hex strings early. To catch both attribute styles in one pass, run this regex against the raw HTML before stripping tags:
const cfEmailRe =
/(?:data-cfemail\s*=\s*["']?([0-9a-fA-F]{6,})["']?|\/cdn-cgi\/l\/email-protection#([0-9a-fA-F]{6,}))/gi;
Two other email extraction traps show up constantly once you parse visible page text:
- Entity-encoded
mailto:links (@,@,@) and human-obfuscated text (sales [at] acme [dot] example) disappear unless you decode HTML entities before running your regex. - Plain regex over HTML pulls in garbage that looks like an email: retina image filenames (
hero@2x.png), Sentry DSN tokens (3f9a...c812@o12345.ingest.sentry.io), and template defaults (user@example.com,info@wixpress.com). Stripping<script>,<style>, and<svg>blocks first, rejecting asset extensions and@2x/@3xsuffixes, and blocking 20+ hex-character local parts eliminates almost all of that noise.
False-positive traps in regex tech fingerprinting
Writing a lightweight BuiltWith alternative looks easy until your regexes run on real marketing copy. Matching /react/i, /stripe/i, /polar/i, or /drift/i against HTML triggers on sentences like "how teams react to incidents", "blue stripe pattern", "polar bear", or "configuration drift".
Every signature needs to anchor on HTTP response headers, third-party script hosts, or framework-emitted DOM markers:
const SIGNATURES = [
{
name: 'Next.js',
headers: { 'x-powered-by': /next\.js/i, 'x-nextjs-cache': /.+/, 'x-nextjs-prerender': /.+/ },
html: [/_next\/static\//i, /__NEXT_DATA__/i, /self\.__next_f\b/i],
},
{
name: 'React',
html: [/\breact-dom\b/i, /\bdata-reactroot\b/i, /_next\/static\//i, /\breact-helmet\b/i],
},
{
name: 'Stripe',
html: [/js\.stripe\.com/i, /checkout\.stripe\.com/i, /\bpk_(?:live|test)_[a-zA-Z0-9]{16,}\b/],
},
{
name: 'Polar',
html: [/buy\.polar\.sh/i, /api\.polar\.sh/i, /@polar-sh\//i],
},
{
name: 'Vercel',
headers: { 'x-vercel-id': /.+/, 'x-vercel-cache': /.+/, server: /^vercel$/i },
html: [/\/_vercel\/insights\//i, /va\.vercel-scripts\.com/i],
},
];
Headers carry high signal because marketing copy cannot forge them. cf-ray identifies Cloudflare, x-vercel-id identifies Vercel, x-amz-cf-id identifies AWS CloudFront, and x-shopify-stage or x-shopid identifies Shopify even on heavily customized storefronts.
Even tight URL patterns still have edge cases. When we ran our detector live on three domains, here is what came back from the homepage HTML and headers alone:
| Domain | Homepage fetch | Detected stack | Homepage emails |
|---|---|---|---|
apify.com |
540ms | Next.js, React, HubSpot, Intercom, GTM, AWS CloudFront, Bootstrap | 0 (2 found after probing /contact and /about) |
polar.sh |
144ms | Next.js, React, Polar, GA4, Cloudflare, Vercel, Tailwind CSS | 1 (support@polar.sh) |
stripe.com |
286ms | Next.js, React, Supabase | 0 |
Notice Supabase on stripe.com. That is a real false positive caused by our [a-z0-9-]+\.supabase\.co pattern matching a customer case-study link or reference URL embedded in the page markup. If you need near-zero false positives for backend services, restrict host regexes to <script src=...> or inline config blocks instead of scanning the full HTML body.
Also notice apify.com: zero emails on the homepage, two emails once we fetched /contact and /about. Probing secondary pages is necessary for contact discovery, which immediately runs into the next bug.
Catching SPA soft-404 catch-alls with a canary request
If a homepage has no link to /pricing, /careers, or /contact, you might probe those paths with HEAD requests to check whether they exist. On traditional servers, a missing /pricing returns 404. On single-page apps deployed to Cloudflare Pages, Netlify, or S3 + CloudFront with a rewrite to index.html, every nonexistent path returns 200 OK.
Without a guard, an enricher reports that every SPA has a pricing page, a careers page, and a contact page.
The fix is to send one parallel canary HEAD request to a random nonexistent path on the same origin:
async function probeKeyPages(origin, existingKeyPages, timeoutMs = 3500) {
const targets = [
{ key: 'pricing', path: '/pricing' },
{ key: 'careers', path: '/careers' },
{ key: 'contact', path: '/contact' },
].filter(({ key }) => !existingKeyPages[key]);
if (targets.length === 0) return {};
const canaryPromise = fetch(`${origin}/__enricher-404-canary-98412`, {
method: 'HEAD',
redirect: 'follow',
signal: AbortSignal.timeout(timeoutMs),
})
.then(async (res) => {
const isCatchAll = res.status >= 200 && res.status < 300;
if (res.body) await res.body.cancel().catch(() => {});
return isCatchAll;
})
.catch(() => false);
const candidates = [];
const [isSoft404CatchAll] = await Promise.all([
canaryPromise,
Promise.allSettled(
targets.map(async ({ key, path }) => {
const probeUrl = `${origin}${path}`;
let res = await fetch(probeUrl, {
method: 'HEAD',
redirect: 'follow',
signal: AbortSignal.timeout(timeoutMs),
});
if (res.status === 405) {
if (res.body) await res.body.cancel().catch(() => {});
res = await fetch(probeUrl, {
method: 'GET',
redirect: 'follow',
signal: AbortSignal.timeout(timeoutMs),
});
}
if (res.body) await res.body.cancel().catch(() => {});
if (res.status < 200 || res.status >= 400) return;
// Ignore servers that redirect unknown paths back to '/'
const finalPath = new URL(res.url || probeUrl).pathname.replace(/\/+$/, '');
if (finalPath === '' || finalPath === '/') return;
candidates.push({ key, url: res.url || probeUrl });
})
),
]);
if (isSoft404CatchAll) return {};
return Object.fromEntries(candidates.map(({ key, url }) => [key, url]));
}
A few details in that helper avoid silent failures. Some web servers reject HEAD with 405 Method Not Allowed, so falling back to GET (and canceling the body right after reading headers) prevents false negatives. Checking finalPath === '' catches servers that 301 or 302 missing routes back to /. Canceling res.body on unused responses keeps Node's undici connection pool from stalling under concurrency.
Running this via API or MCP
If you do not want to maintain the signature list, phone/email filters, and concurrency pool yourself, we packaged this exact zero-proxy Node 22 engine (with 75+ B2B/SaaS tech signatures) as our own Apify Actor: Website Lead & Tech Stack Enricher. For Shopify stores specifically, we built a separate Actor that adds 55+ Shopify app fingerprints and /products.json / /search/suggest.json catalog pricing at Shopify Store Intelligence. You can trigger a synchronous batch over REST (or call it directly from Claude or Cursor through the Apify MCP server):
curl -s "https://api.apify.com/v2/acts/immortal_swale~website-lead-tech-enricher/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"urls": ["https://apify.com", "https://stripe.com", "https://polar.sh"], "checkKeyPages": true}'
Top comments (0)