Lead Scraping & Lead Generation

Everything from Claude Code and Codex sessions, Apr – Nov 2026. Compiled 26 Nov 2026. Secrets and scraped contact details left out; counts only.

921
beta leadgen_leads rows (Jul 23)
1,041
Link-in-bio CRM leads on prod
130
agency phones on beta (from 4)
609
SuperProfile/Topmate records
226
Harvey cold emails · 0 replies
~$0.06
Cloudflare cost for 794 profiles

In one line: started with Apify-heavy Instagram creator scraping, moved profile enrichment to Meta Graph then Cloudflare Browser Rendering (near-free), then shifted discovery to agent-driven web research (Linktree, agencies, storefronts, Meta Ad Library) and an autonomous outbound agent (Harvey). Cold email to generic inboxes has produced no replies so far.

Architecture evolution

WhenApproachStatus
Apr 2026Standalone lead-generation repo (FastAPI + Next.js), Apify discovery + instagrapi enrichment, 100-pt scoring, Resend emailsparked
May 16Pipeline moved into Flask leadgen/ + /api/leadgen/* (flask#147); CRM lead-gen pageslive on beta
JunInternal cohort leads from workspaces_new (Link-in-bio, halted automations)live prod
Jul 5–10ZOR-305: replace Apify profile fetch with Meta business_discovery via Zorcha AI tokens; CRM hourly cron → ai_personasfallback only
Jul 11+Cloudflare Browser Run inside CRM worker + Instagram public web_profile_info JSON; Google-indexed discovery optioncron failing Sep 11
Jul 22Standalone scraper Worker: public JSON → embed HTML → Browser Run fallback (crm#452)healthy
Jul 23–24Agent-driven web research: Linktree + wa.me, Stan storefronts, agency websitesone-off
Sep 16–17lead-generation agency mode; Apify replaced with free web search (PR #4 open)unmerged
OctSuperProfile/Topmate storefront research → Sheets; then mining existing Zorcha sellersone-off
Oct 14 – NovHarvey autonomous outbound agent (Serper / DDG via Cloudflare, Meta Ad Library, Reoon, Gmail warm inboxes)active

Systems

1. lead-generation repo (Zorcha/zorcha-lead-gen)

Purpose: find IG creators selling digital products with "comment LINK below" triggers; score; email.
Stack: FastAPI + SQLAlchemy + asyncio · Next.js 16 / React 19 / shadcn · Tiptap editor · WebSocket run logs · Resend (cold + transactional accounts).
Stores: leadgen.db (runs, leads, emails, reports), raw_datalake.db (raw Apify responses → re-score without re-scraping). Postgres via DATABASE_URL since Apr 11.
Run: .env with APIFY_API_TOKEN (+ optional OpenAI/Resend) → bash start-pm2.sh (API :8000, UI :3000). GH Actions → EC2 pm2.

Agency mode (Sep 16–17, Claude):

  • Discovery: site:linkedin.com/company "<query>" <city>, query × city buckets interleaved.
  • Site crawl of agency domain (home/about/team). Contacts from site:linkedin.com/in "<company>" founder snippets — no LinkedIn requests.
  • Phones: tel: / wa.me → contact page → regex, E.164.
  • IG-focus gate: agency evidence + IG signal (instagram/reels/influencer/ugc/personal branding) or own IG ≥500 followers.
  • First version used paid Apify actors (Google SERP, LinkedIn company ~$3/1k, employees ~$4/1k); rewritten to free web search on user request.
  • Free run: 6 agencies, 18 contacts, 5 emails in ~3 min. IG-focused run: 51 found → 13 leads, 21 contacts, phones 3/13.

2. Flask leadgen module (zorcha_flask)

14+ endpoints under /api/leadgen/: health, runs (list/get/delete/create), leads (list/get/enrich), config (get/put), stats, usage, export. CRM pages under zorcha-crm app/routes/dashboard/lead-gen/ proxy it. "New Run" modal supports discovery_source = hybrid / google_indexed / apify.

Detailed write-up: zorcha_flask_leadgen_outreach_pr/leadgen_pipeline_stages.md

3. lead-gen-test (measurement only)

Node/Playwright audit of how many comment-to-DM accounts Google + public IG expose. No login, no CAPTCHA bypass. queries.txt (e.g. site:instagram.com/reel/ "comment LINK" after:2026-01-01). npm run google|full|all -- --country us → reports/<ts>/report.html|json, leads.csv. First Google-only probe hit CAPTCHA, 0 links. Inspired Google-indexed discovery in Flask; not ported.

Flask pipeline stages

0 · config + budget (leadgen_kv)→1 · Apify discovery→2 · profile enrich→3 · follower filter→4 · classify, contacts, score, LLM report→5 · usage metrics
StageDetail
0Load run config/budget; stop early if lifetime Apify budget exhausted.
1 Discoverypatient_discovery/instagram-search-reels (richest, virality metrics) · sasky/instagram-keyword-posts-urls-scraper (3 months) · apify/instagram-hashtag-scraper. Dedupe by owner: reels > keyword > hashtag. Alt: Google CSE indexed discovery.
2 EnrichOriginally instagrapi + 7-day profile_cache, 2–5 s jitter, account rotation (#192). Later: profile_cache → Meta business_discovery → Cloudflare scraper.
3 Filtermin/max followers (min_followers: 0 or 1000 default bug fixed).
4 QualifyOptional India filter (later: tag country_hint=india_hint instead of skip). Caption tiers T1 explicit comment-to-DM, T2 ManyChat/Chatfuel, T3 "link in bio", T0 skipped. Viral comment detector (≥30% same short word → T1). Email from bio (incl. at/dot obfuscation) + website + ≤2 contact pages. Phone via phonenumbers. Deep enrich Linktree/Beacons/Stan → SERP fallback. LLM report "The Gap" + "Outreach Hook".
5Persist Apify units, OpenAI tokens/cost.

Scoring & ICP

Creator score (100 pts)Pts
Content / intent35
Automation maturity30
Virality17
Account health14
Audience (penalty >1M)8

Tiers: Hot ≥60 (auto-queued for OpenAI research report), Warm 35–59, Cold <35. Brand accounts filtered. AgencyScorer: IG focus, contacts, email, website, 5–200 staff. profile_type = business / creator / personal / unknown from web_profile_info.

Cloudflare scraping

Standalone Worker zorcha-leadgen-browser-scraper-beta — scraper-only, no Postgres, BROWSER binding only. POST /api/internal/leadgen/browser-run/preview-profile, bearer LEADGEN_BROWSER_RUN_TOKEN (timing-safe compare), host allowlist. Order: IG public JSON → embed HTML → Browser Run.

CRM hydration cron in zorcha-crm, 0 * * * *, runLeadgenProfileHydrationCron. Candidates: raw_posts usernames with no profile_cache row in 30 days, max 50/batch. Writes only profile_cache, never leadgen_leads. Manual trigger POST /api/internal/leadgen/profile-hydration/run. Sep 11: 50 selected / 0 hydrated / 50 failed (Browser Run WebSocket errors). crm#568 (Sep 30) moved it to admin DB; not re-verified.

Why web_profile_info: SEO meta tags gave bio + counts but 0/25 external URLs. JSON gives external_url, bio_links, business/professional flags, category, business email/phone. Validation vs 25 known leads: 25/25 hydrated, 14/16 bio emails recovered.

Review hardening (crm, 4 rounds): public contacts only if should_show_public_contacts === true; sparse embeds never overwrite cache; libphonenumber to reject order IDs/ISBNs/timestamps; embed captions only when owner matches.

Limits: Workers fetching Instagram directly hit login redirects + 429s; follower counts sometimes needed real browser checks. Reel view counts not collected (needed for a Modash-style avg-views calculator).

Discovery waves

DateTargetMethodResult
Jul 11–26Comment-to-DM creators, competitor users (ManyChat/Wishlink)Flask hybrid Google/Apify + Cloudflare hydrationCompetitor run 19 leads / 5 emails. 1,000 push: 794 leads, 34 emails, 0 phones (stopped on Meta Graph limits)
Jul 21–22Phones for existing leadsbio_links, wa.me, tel:, website contact pages, JSON-LD; backfill_leadgen_phone_cache.py (dry-run, --apply)+24 phones on beta (25 total)
Jul 23Phone-rich IG creators, 6 regionsLive Linktree pages with IG + wa.me; country from calling code180 usernames (30/region)
Jul 23ManyChat-style creatorsStan storefronts + 2026-indexed search25 (stopped early; weak ManyChat evidence)
Jul 24IG-focused agencies (ME, EU, Americas, Africa)First-party agency websites, 1,255-name exclusion list90 validated; beta agency phones 4 → 130 (117 Hot); 76 emails + 67 contact forms not attached to DB
Sep 5Mumbai finance creators already on ZorchaInternal: bios, DM-geo aggregates, follower-city insights, PostHog geo123 accounts (9 self-stated Maharashtra); skill zorcha-brand-collab-discovery (support_agent#115)
Oct 2–8SuperProfile / Topmate sellers3-stage CF Worker + D1 (crm#574 draft); search-indexed pages (Vercel checkpoint blocked live); storefront → product → seller-support609 records, 503 product prospects, 204-number phone sheet; 47 India ₹500+ sellers; 130 IG handles
Oct 8Existing Zorcha paid sellersInternal DB + ban/availability checks182 verified paid sellers → Sheets for sales

Harvey outbound agent (Oct 14 – Nov)

Fork of ethanplusai/harvey at z/harvey (local zorcha branch). Python, SQLite, dashboard :5555. Loop: discover → profile → enrich → verify → write → send, each message must pass harvey.gate. Zorcha additions: IG/FB signals, harvey import <csv>, SMTP reply-to, footer.

Sources: Serper (Google) · httpx site profiling · Cloudflare Browser Rendering + DuckDuckGo (after Serper credits hit 0) · Meta Ad Library (no login) → advertiser FB page contact info · Reoon email verification · PostHog check to exclude existing users.

Sending: Resend from send.zorcha.com, then Gmail-scheduled from warmed zorcha.app (~15/day) and zorcha.ai (~5/day) inboxes via browser control.

DateRunNumbers
Oct 15–16UAE businesses152 profiled → 47 Resend sends; +351 companies found, 200 profiled (per-run cap)
Oct 17Built-in contact finderPerson found at 4 of ~90 businesses
Oct 31Owner research118 businesses → owners for 57 (48%)
Nov 6Owner research + Reoon+114 owners (171 total); 20 Reoon checks: 3 safe, 10 invalid, 2 spam traps; Meta Ad Library test: 28 UAE click-to-chat advertisers
Nov 11–15Gmail warmup sends162 sent from zorcha.app; 22 follow-ups; 1 bounce, 0 replies
Nov 18US niches174 profiles → 159 Reoon-safe emails; held (needs CAN-SPAM postal address)
Nov 19India pivot (85% of paid users in India)Meta Ad Library "bridal makeup delhi" ~960 ads → 35 advertisers → 17 safe emails, scheduled Nov 22–23
Nov 22Reply check226 contacted, 0 replies. India batch to judge ~Nov 26–27

Email outreach (Flask)

Internal cohort leads (no scraping)

Instagram ban scraper

zorcha_scripts/check_paid_past_instagram_ban_status.ts + instagram_validity_worker.ts. Cloudflare Browser Rendering probes public profile → workspaces_new.is_banned timestamp (schema#82): banned → NOW(), valid → NULL, unknown untouched. Dry-run default, --apply, --segment=sleeping-leads-5k. Prod Sep 7: 4,100 → 737 banned / 2,557 valid / 806 unknown. Limit: DM-restricted accounts look normal publicly (anonymous probe caught 0 of 38 confirmed bans); real signal is Meta error 368.

Data stores

StoreHolds
Admin Postgres (beta / prod)raw_posts (discovered usernames, acts as queue), profile_cache, leadgen_runs, leadgen_leads (phone_number, metadata.phone_source, cloudflare_instagram_profile, country_hint, automation post), emails, CRM leads
Main DBai_personas (hydrated profile facts), workspaces_new.is_banned, users bounce fields
D1 / KVSuperProfile pipeline; beta.zorcha.link preview pages
Google SheetsSuperProfile, agency and seller lead lists shared with sales
Localharvey/data/ (git-ignored), lead-generation/backend/output/*.csv, support_agent/reports/…, reports/…

Costs

Timeline

DateEvent
Apr 4–12lead-generation built: dashboard, Postgres, Tiptap, dual Resend, EC2 CI/CD
May 16–21Pipeline into Flask (flask#147); instagrapi rotation (#192)
Jun 19–21Link-in-bio leads; emails table + Apify concurrency (flask#256)
Jul 5–10ZOR-305 hydration design: Meta Graph + CRM cron
Jul 11–13Flask discovery + email queue (#278); Cloudflare Browser Run in CRM; first 10 cold emails
Jul 16–26Gmail button, phone recovery, standalone scraper (crm#452), 794-lead push, Resend webhooks, outreach docs (docs#121)
Jul 23–24Linktree/Stan/agency discovery waves; beta leads 921, agency phones 130
Aug 4Resend bounce webhook prod fix (#319)
Sep 5–7Brand-collab creator skill; IG ban scraper prod run
Sep 11CRM hydration cron found failing 50/50
Sep 16–17Agency mode; Apify removed (PR #4); Browser Run access for Harsh
Sep 30Hydration cron to admin DB (crm#568)
Oct 2–8SuperProfile/Topmate discovery; 182 verified paid Zorcha sellers
Oct 14 – Nov 22Harvey: UAE → owners → US (held) → India Meta-ads; 226 sent, 0 replies

Current state

ItemState
Link-in-bio CRM leadslive prod
Flask leadgen API + Resend queue + webhooksbeta webhook on prod
Standalone CF scraper Workerhealthy
CRM hydration cronfailing Sep 11 fix #568 unverified
lead-generation agency mode (free search)PR #4 open 11 uncommitted files
Harveyactive India batch pending judgement
Meta Graph hydration / Apifyfallback
lead-gen-test, FastAPI SQLite modeabandoned

Open items

  1. Nothing writes standalone scraper results into leadgen_leads; hydration never creates leads.
  2. CRM hydration cron Browser Run WebSocket failures — verify after crm#568.
  3. Agency emails (76) + contact forms (67) not attached to leadgen_leads.
  4. Emails queued in beta admin DB never drain (prod cron points at prod admin). No unsubscribe header; no reply tracking.
  5. Hardcoded legacy Resend key in a tracked Flask helper; several keys pasted in chats (Cloudflare, Serper, Reoon) and in old memory — rotate.
  6. Flask open PRs: #281 Resend events, #188, #257 Apify quota fail-fast, #210 SSM mapping. Processor #537/#541 not on main.
  7. Beta Flask leadgen endpoints have no own auth; daemon-thread runs lost on restart and stale runs eat 5-run limit.
  8. SuperProfile migration previews blocked (frontend#803 404, importer 403); crm#574 draft.
  9. Harvey: 159 US leads held for CAN-SPAM address; Gmail API sending needs user-owned Google Cloud OAuth.
  10. IG ban: refresh is_banned in update-user-details path; periodic revival re-check.

Lessons

  1. Google blocks fast. CAPTCHA on first probe, 429s on agency runs. Serper credits run out; DDG via Cloudflare Browser Rendering works as fallback.
  2. LinkedIn: no direct scraping (login walls). Search snippets give names; verify title/company match.
  3. Tight ICP gate needed. "Marketing agency" queries return IT/import firms; require agency words + IG signal.
  4. Generic inboxes don't reply. 226+ cold emails, 0 replies. Better: verified owners, businesses already paying for click-to-chat ads, India market.
  5. Deliverability: product-heavy copy → Promotions; short human notes → Inbox. Warm separate domains, respect warmup limits.
  6. Env mismatch kills pipelines: rows in beta DB, cron on prod. Confirm stage before prod sends.
  7. Defensive guards hide failures: ban scraper "ran 10 s and did nothing". Enable per-worker observability.
  8. Scraped lists are not opt-in: no bulk sends, keep out of git, never re-send to bounced addresses.
  9. Cheapest path first: public JSON before headless browser cut Browser Run cost to ~0.

Runbook

TaskHow
Trigger prod CRM lead pipelineQueue run_leads_pipeline; check scheduler_logs queue_leads_pipeline | COMPLETED
Local lead generation testcd zorcha_processor/event-handling/processor && STAGE=beta PYTHONPATH="$(pwd):$(dirname "$(pwd)")" python3 local_test.py leads_generation
Start standalone lead-gen appcd lead-generation && bash start-pm2.sh
Schedule leadgen emailspython scripts/schedule_leadgen_emails.py (dry-run), add --apply
Phone backfillscripts_unreferenced/backfill_leadgen_phone_cache.py --run-id … --limit …, then --apply
IG ban checkzorcha_scripts/check_paid_past_instagram_ban_status.ts [--segment=sleeping-leads-5k] [--apply]
Manual hydrationPOST /api/internal/leadgen/profile-hydration/run (bearer) on CRM worker

Sources

Codex threads (19): Link In Bio leads, Replace Apify profile fetch / Lead gen BRo, Design lead email pipeline, Trace browser scraper flow, Inspect beta candidates, Safe phone backfill, Review IG scraper diff, Find 150 IG leads ×2, Discovery entrypoints, Audit beta leadgen data, Agency leads ×2, Creator search skill, Check Cloudflare scraping ×2, SuperProfile discovery. Claude Code sessions Sep–Nov (agency mode, Harvey, link-in-bio success, ban detection). Repos: lead-generation, lead-gen-test, zorcha_flask leadgen, zorcha-crm, zorcha_scripts, harvey. Docs: leadgen_pipeline_stages.md, leadgen/outreach_playbook.md, zorcha-docs LEADGEN_CURRENT_STATE.md.