DEV Community

Aurelix Solutions
Aurelix Solutions

Posted on

Canadian business lead lists from YellowPages.ca in Python, with phone, website, address and hours

Agencies, local-service sellers and B2B sales teams in Canada still build prospect lists from YellowPages.ca: every plumber in Toronto, every dentist in Halifax, with a phone number and a website. Copying them by hand means messy addresses, tracking redirect links instead of real websites, and the same paid listing showing up three times.

This post turns YellowPages.ca searches into a clean lead list in Python, finds businesses without a website, counts businesses by city and category, and sets up a scheduled run that returns only new businesses.

Disclosure: I'm Aurelix, and I built Yellow Pages Canada Scraper, the tool used here. It's a paid tool (prices below).

What each row holds

22 fields per business:

  • name, category, categories, is_ad (a paid placement).
  • street, city, province, postal_code, latitude, longitude.
  • phone in E.164 (e.g. +16475550123) and website, with YellowPages.ca redirect links and social pages removed.
  • rating, review_count, open_status, hours (a list of {day, opens, closes}).
  • listing_id, yp_url, search_term, search_location, scraped_at.

Plumbers and electricians in two cities

pip install apify-client
Enter fullscreen mode Exit fullscreen mode
import csv
import os

from apify_client import ApifyClient

client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("aurelix/yellow-pages-canada-scraper").call(
    run_input={
        "searchTerms": ["plumber", "electrician"],
        "locations": ["Toronto ON", "Calgary AB"],
        "maxResultsPerSearch": 100,
        "includeDetails": True,
    }
)
leads = list(client.dataset(run["defaultDatasetId"]).iterate_items())

fields = ["name", "category", "phone", "website", "street", "city", "province", "postal_code", "rating", "review_count", "is_ad"]
with open("yp_leads.csv", "w", newline="", encoding="utf-8") as f:
    w = csv.DictWriter(f, fieldnames=fields, extrasaction="ignore")
    w.writeheader()
    w.writerows(leads)
Enter fullscreen mode Exit fullscreen mode

Every search term runs in every location, and a business found twice is returned once. includeDetails (on by default) opens each business page for opening hours, the exact rating and coordinates; turn it off for a much faster card-only run.

Businesses with no website, and who dominates each city

from collections import Counter

no_site = [b for b in leads if not b["website"] and b["phone"]]
print(f"{len(no_site)} of {len(leads)} businesses list a phone but no website")

organic = [b for b in leads if not b["is_ad"]]
print("by city:", Counter(b["city"] for b in organic).most_common(5))
print("by category:", Counter(b["category"] for b in organic).most_common(5))
Enter fullscreen mode Exit fullscreen mode

A list of businesses with a phone and no website is a ready prospect list for web designers and local marketing agencies.

Only new businesses on a schedule

run_input = {
    "searchTerms": ["dentist"],
    "locations": ["Halifax NS", "Moncton NB"],
    "incremental": True,
    "stateKey": "dentists-maritimes",
    "slackWebhookUrl": "https://hooks.slack.com/services/...",
}
Enter fullscreen mode Exit fullscreen mode

With incremental on, the first run returns everything that matches and each later run skips businesses an earlier run already returned; known businesses are not charged again. Save the input as a task in the Apify Console and schedule it weekly: Slack gets a short digest of new listings, and nothing is sent when there are none. webhookUrl posts the same digest as JSON to Zapier, Make, n8n or your CRM.

Why this tool

  • Clean addresses: street, city, province and postal code split; phones in E.164.
  • Real websites, not tracking redirects.
  • Opening hours from each business page, or a faster card-only run.
  • Paid placements flagged with is_ad.
  • Cheaper than the leading tools.

Limits

  • Canada only (YellowPages.ca); the US site is not covered.
  • Results are what YellowPages.ca shows for the search, in its order, including paid placements; very broad searches stop when the site stops returning new businesses.
  • No emails: the tool does not collect them.
  • Opening hours are as listed by the business and can be out of date.

Cost

$1.50 per 1,000 businesses on Apify's free plan, from $0.84 per 1,000 on paid plans, plus a start fee per run. Duplicate listings, failed pages and the business pages opened for hours are not charged. The current prices are on the Store page; Apify's free plan includes $5 of credit a month, about 3,300 businesses.

Use it from an AI assistant

The tool also works through Apify's hosted MCP server, so Claude, ChatGPT or Cursor can run it from a request like "list roofers in Ottawa ON with phone and website from Yellow Pages". Server URL: https://mcp.apify.com/?tools=aurelix/yellow-pages-canada-scraper.

Links

Top comments (0)