How to Automate LinkedIn Lead Scoring with Python Rules Engine
If you're tired of manually filtering through thousands of LinkedIn profiles, this Python script will change everything. Sales teams often rely on LinkedIn Sales Navigator or Recruiter exports to find leads, but sorting through them by hand is time-consuming and error-prone. You end up spending hours sifting through irrelevant profiles, missing high-potential prospects, and hitting API limits that prevent automation.
The Manual Way (And Why It Breaks)
Most developers and sales professionals start by exporting a CSV from LinkedIn and then open it in Excel or Google Sheets. From there, they copy-paste titles, company names, and other fields into formulas or filters to prioritize leads. It's tedious, especially when you need to apply complex rules like “only people in C-level roles at Fortune 500 companies.” The process breaks down quickly: formulas get messy, filters are hard to maintain, and you can’t scale beyond a few hundred leads without hitting platform throttling limits.
The Python Approach
Here’s a minimal version of how you might automate basic lead scoring in Python:
import csv
def score_lead(profile, rules):
score = 0
title = profile['title'].lower()
company = profile['company'].lower()
location = profile['location'].lower()
# Score based on title keywords
for keyword in rules.get('title_keywords', []):
if keyword in title:
score += 10
# Score based on company
for keyword in rules.get('company_keywords', []):
if keyword in company:
score += 5
# Exclude certain roles
exclude_titles = rules.get('exclude_titles', [])
for exclude in exclude_titles:
if exclude in title:
score = -100 # Negative score to filter out
return score
# Load profiles and apply scoring
with open('leads.csv') as f:
reader = csv.DictReader(f)
profiles = list(reader)
# Define scoring rules
rules = {
'title_keywords': ['director', 'manager', 'vp', 'cto'],
'company_keywords': ['inc', 'corp', 'llc'],
'exclude_titles': ['recruiter', 'hr']
}
# Score and sort
for profile in profiles:
profile['score'] = score_lead(profile, rules)
profiles.sort(key=lambda x: x['score'], reverse=True)
# Output results
with open('prioritized_leads.csv', 'w', newline='') as f:
writer = csv.DictWriter(f, fieldnames=profiles[0].keys())
writer.writeheader()
writer.writerows(profiles)
This code loops through a list of LinkedIn profiles, scores each one based on defined rules, and sorts them. It works well for small datasets but lacks error handling, input validation, and support for complex filters or multiple data sources. Scaling it up requires more work — and it’s easy to miss edge cases.
What the Full Tool Handles
The Professional Network Automation Rule Engine solves these issues with:
- Built-in CSV support for Sales Navigator and Recruiter exports
- Configurable rules with logical operators and dynamic scoring
- Error handling and graceful fallbacks for malformed data
- CLI interface for batch processing
- Output options including clean CSV or JSON
Running It
Using the tool is simple:
linkedin_rules --input leads.csv --config rules.json --output prioritized_leads.csv
The --input flag points to your LinkedIn CSV export. The --config flag specifies the JSON file containing your scoring criteria, such as which roles to include or exclude. The --output flag tells the tool where to save the cleaned and ranked results.
Results
You get a prioritized list of leads, ready for outreach, with all the filtering and scoring applied automatically. Time savings are significant — tasks that once took hours now complete in minutes. You’ll have a clean CSV file with a calculated lead score and no manual intervention needed.
Get the Script
If this approach feels like the right direction but you don’t want to write or maintain the code, the Professional Network Automation Rule Engine is your solution. Skip the build and get a ready-made tool that handles everything from input parsing to output formatting.
Download Professional Network Automation Rule Engine →
$29 one-time. No subscription. Works on Windows, Mac, and Linux.
Built by OddShop — Python automation tools for developers and businesses.
Top comments (0)