DEV Community

Siftwright
Siftwright

Posted on

Extract emails, phones and social links from a list of websites with Python

Sales and research scripts often start with "get me a contact address for each company on this list." Here is a small Python script that does it with the Contact Details Extractor Actor on Apify, plus the real output from a test run today.

What it returns

For each website you give it, the Actor scans the home page and a few likely contact pages and returns emails, phones and social profile links. Only addresses actually found on the pages are returned (no guessing, no pattern-generated emails).

Python

from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("siftwright/contact-details-extractor").call(run_input={
    "startUrls": ["https://stripe.com", "https://www.python.org", "https://apify.com"],
    "maxPagesPerDomain": 3,
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["domain"], item["emails"], item["phones"], item["linkedin"])
Enter fullscreen mode Exit fullscreen mode

Real output (test run, 3 sites, 3 pages each)

domain emails phones linkedin
stripe.com sales@stripe.com +1 888 926 2289 yes
apify.com hello@apify.com none found yes
www.python.org none found none found yes

Note the honest part: python.org's scanned pages publish no email, so the result is an empty list. A status field tells you whether the site loaded, and you can see how many pages were scanned.

Pricing

Pay per event: about $0.002 per website. The three-site test above cost well under a cent. New Apify accounts get free monthly credit, so you can try it without paying.

curl

curl -X POST "https://api.apify.com/v2/acts/siftwright~contact-details-extractor/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"startUrls":["https://apify.com"],"maxPagesPerDomain":3}'
Enter fullscreen mode Exit fullscreen mode

Try it: https://apify.com/siftwright/contact-details-extractor . It also works from AI agents through Apify's MCP server.

Top comments (0)