mz_chatbot / scripts /check_linkedin_search.py
Shurem's picture
added multiple changes
ecef140
Raw History Blame Contribute Delete
2.53 kB
"""
check_linkedin_search.py — does the search-first LinkedIn finder name the RIGHT people?
Read-only, no database writes. For each company it runs
agent_core.find_people_via_search() -- the real web search behind "AI Research
LinkedIn" and the free last-resort in "Find decision makers" -- and prints the
name, title and profile URL it found. You eyeball them: open a couple of URLs and
check the person really runs that company. That, not this script, is the accuracy
test.
uv run python scripts/check_linkedin_search.py "ICON 4x4" "Tidewater Golf Cars"
uv run python scripts/check_linkedin_search.py --from-db 10 # 10 leads with no LinkedIn yet
Uses DuckDuckGo; add SERPER_API_KEY to .env to let Serper.dev back it up.
Each company is 1-2 web searches, so keep the list short.
"""
from __future__ import annotations
import argparse
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from app.config import settings # noqa: E402,F401 (loads .env)
from app.services import agent_core # noqa: E402
def main() -> int:
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument("companies", nargs="*", help="company names to look up")
ap.add_argument("--from-db", type=int, default=0, metavar="N",
help="take N leads that have a company but no LinkedIn URL from the CRM")
args = ap.parse_args()
names = list(args.companies)
if args.from_db:
from sqlalchemy import select
from app.database import SessionLocal
from app.models import Lead
with SessionLocal() as db:
names += [
l.company_name
for l in db.scalars(
select(Lead).where(Lead.contact_linkedin == "").order_by(Lead.id.desc()).limit(args.from_db)
).all()
]
if not names:
print("Give company names, or --from-db N.")
return 1
found = 0
for name in names:
people = agent_core.find_people_via_search(name, limit=2)
found += bool(people)
print(f"\n{name}")
if not people:
print(" -- nobody found (search returned no matching, live LinkedIn profile)")
for p in people:
print(f" {p['name']:26} {p['position'][:34]:34} {p['linkedin']}")
print(f"\n{found} of {len(names)} companies returned at least one person.")
return 0
if __name__ == "__main__":
sys.exit(main())