DEV Community

Extracting Clean B2B Emails, Phones, 7 Social Networks & JSON-LD Addresses in 128 MB RAM (Zero Headless Browsers)

Most B2B contact scrapers make two expensive mistakes: they boot a full Chromium instance just to read static /contact and /about pages, and they run naive email regexes over $('body').text() that leak l***@2x.png, ingest.sentry.io, wixpress.com, and fused HTML table text like h****@company.comProduct.

We built an open-source TypeScript + Cheerio Apify Actor (GitHub | Apify Store) that extracts clean B2B contact graphs inside a 128 MB RAM container at $2.00 / 1,000 domains:

Key Engineering Decisions

  • Direct Node Entrypoint + Bounded Streaming (128 MB RAM): Launching via CMD ["node", "--max-old-space-size=88", "dist/main.js"] removes ~35 MB of npm parent overhead, and bounding HTML stream reads at 750 KB with sequential per-domain subpage crawling keeps peak container memory at 101.1 MB (35.7 MB average).
  • Tag-Boundary Text Extraction (Zero Fused Emails): Instead of calling Cheerio's $('body').text() directly (which glues adjacent <td> or <span> nodes together into bogus TLDs like .comproduct), walking DOM text nodes and joining with spaces prevents element boundary bleed completely.
  • Cloudflare data-cfemail Decoding + Strict Junk Filtering: Automatically decodes XOR-obfuscated Cloudflare emails, strips asset suffixes (.png, .jpg, .svg, .woff2), blocks tracker/placeholder domains (sentry.io, wixpress.com, example.com), and classifies every address as role (sales, support, info, legal, hr, press, billing, security) or personal.
  • 7-Network Social Canonicalization + JSON-LD: Extracts and canonicalizes LinkedIn, X/Twitter (deduped across twitter.com and x.com handles), Instagram, Facebook, YouTube, GitHub, and TikTok, alongside Organization / LocalBusiness JSON-LD address and contactPoints.

Verified Live Apify Cloud Benchmark (128 MB RAM)

Across 5 real business domains (apify.com, hubspot.com, basecamp.com, ycombinator.com, resend.com, up to 4 pages/domain):

  • Total Run Time: 14.93s (5.06s extraction)
  • Peak Container RAM: 101.1 MB (35.7 MB average)
  • Extracted: 16 verified emails, 56 phone numbers, 42 social profile URLs, and full JSON-LD addresses
  • Compute Units: 0.0005184 CU (~0.104 CU / 1,000 domains, $0.0002419 platform cost)

Use as a Hosted MCP Server

{
  "mcpServers": {
    "apify-b2b-contacts": {
      "url": "https://mcp.apify.com/?actors=deliberate_gratitude_shj/b2b-contact-social-extractor",
      "headers": {
        "Authorization": "Bearer <YOUR_APIFY_TOKEN>"
      }
    }
  }
}
Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.