Digital marketing agencies need a steady flow of qualified leads: local businesses that need websites, SEO, or digital marketing services. Manual prospecting on Google Maps takes 4-6 hours per session for 30-40 leads. This tutorial automates the pipeline: search for businesses in target niches and cities, evaluate their online presence, score them by opportunity, and export qualified leads for outreach.
Prerequisites
- Python 3.8+ installed
- requests library installed
- A Scavio API key from scavio.dev
- A list of target niches and cities
Walkthrough
Step 1: Define your target niches and cities
Set up the search matrix: which business types in which locations.
NICHES = ['plumber', 'electrician', 'dentist', 'restaurant', 'auto repair']
CITIES = ['Austin TX', 'Denver CO', 'Portland OR', 'Nashville TN']
API_KEY = os.environ['SCAVIO_API_KEY']Step 2: Search for businesses
Query Google for each niche-city combination to find local businesses.
import requests, os
H = {'x-api-key': API_KEY}
def find_businesses(niche: str, city: str) -> list:
resp = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
json={'platform': 'google', 'query': f'{niche} {city}'}, timeout=10)
return [{'name': r['title'], 'url': r.get('link', ''), 'snippet': r.get('snippet', '')}
for r in resp.json().get('organic', [])[:10]]Step 3: Score each lead by opportunity
Evaluate the lead's online presence to estimate how much they need your services.
def score_lead(lead: dict) -> dict:
url = lead.get('url', '')
score = 5 # baseline
# No website or directory listing only
if 'yelp.com' in url or 'yellowpages' in url:
score += 3 # high opportunity, no owned website
# Check for reviews mention in snippet
snippet = lead.get('snippet', '').lower()
if 'no reviews' in snippet or 'be the first' in snippet:
score += 2 # low online presence
lead['opportunity_score'] = min(score, 10)
return lead
# Score all leads
scored = [score_lead(l) for l in leads]Step 4: Run the full pipeline and export
Iterate through all niche-city combinations, score leads, and export the top ones.
import csv, time
def run_pipeline() -> list:
all_leads = []
for niche in NICHES:
for city in CITIES:
businesses = find_businesses(niche, city)
for b in businesses:
b['niche'] = niche
b['city'] = city
score_lead(b)
all_leads.append(b)
time.sleep(0.5)
all_leads.sort(key=lambda x: x['opportunity_score'], reverse=True)
with open('qualified_leads.csv', 'w', newline='') as f:
w = csv.DictWriter(f, fieldnames=['name', 'niche', 'city', 'url', 'opportunity_score'])
w.writeheader()
w.writerows([{k: l[k] for k in ['name', 'niche', 'city', 'url', 'opportunity_score']} for l in all_leads[:50]])
print(f'Exported top 50 of {len(all_leads)} leads')
return all_leads
run_pipeline()Python Example
import requests, os
H = {'x-api-key': os.environ['SCAVIO_API_KEY']}
def prospect(niche, city):
data = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
json={'platform': 'google', 'query': f'{niche} {city}'}, timeout=10).json()
return [{'name': r['title'], 'url': r.get('link', ''), 'directory_only': 'yelp' in r.get('link', '')}
for r in data.get('organic', [])[:10]]JavaScript Example
async function prospect(niche, city) {
const data = await fetch('https://api.scavio.dev/api/v1/search', {
method: 'POST', headers: {'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json'},
body: JSON.stringify({platform: 'google', query: `${niche} ${city}`})
}).then(r => r.json());
return (data.organic || []).slice(0, 10).map(r => ({name: r.title, url: r.link}));
}Expected Output
A CSV of qualified local business leads scored by opportunity, ready for import into outreach tools like Instantly or Smartlead.