Skip to content

About

Async CSV enrichment of companies and domains from the live web: website, description, emails and social profiles with sources, via SpecStream fast search ($1/1K) and Extract ($0.80/1K). Stdlib only.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Async CSV enrichment from the live web with SpecStream

Give it a CSV of company names or domains; it returns each company's website, homepage title, a description read from the page, the emails and LinkedIn, X and GitHub profiles the homepage prints, and the pages each value came from. It runs on SpecStream, the live web data engine: a fast web search finds the site when a row has only a name, and the Extract API reads up to 20 homepages per call. Python 3.9+, standard library only, asyncio with as many calls in flight as you set.

Step API Price
Find the website of a row with only a name GET /v1/web-search?speed=fast $1 per 1,000 searches, 937 ms median
Read the homepage, its emails and its links POST /v1/extract with include: ["links"] $0.80 per 1,000 pages

So 10,000 rows with names only cost at most $18, and 10,000 rows that already carry a domain at most $8. New accounts get $2 of free credit, which is 2,000 fast searches, with no card.

Run

git clone https://github.com/specstream/python-async-specstream-enricher
cd python-async-specstream-enricher

python enrich.py examples/companies.csv enriched.csv --dry-run      # prices the run, no key, no call
export SPECSTREAM_API_KEY=your_key                                   # Agents & API at specstream.ai/workspace
python enrich.py examples/companies.csv enriched.csv --max-usd 1
5 rows, 0 already in enriched.csv, 5 to enrich: at most $0.0070 (fast search $1 per 1,000, page read $0.80 per 1,000)
5 of 5 rows, $0.0070 spent

The input needs a company (or name, organization, account) column, a domain (or website, url) column, or both; name others with --name-col and --domain-col. Every input column is kept as it is, and these are added (when the input already has a column of the same name, the found value goes to specstream_<name>):

Column What it holds
website the domain given, or the first search result that is the company's own site and not a directory or profile
title, description the homepage's title and its first real paragraph, read live
emails the addresses the homepage prints
linkedin, x, github the company profiles the homepage links to
read_status ok, or why the page gave no text: blocked, not_found, empty, failed
sources the homepage read and the search results the website came from
enriched_at when the row was read, UTC

What it does for throughput and safety

  • Searches and page reads run at once, up to --concurrency (16 by default), and homepages go 20 to an Extract call.
  • --max-usd is a hard cap: the run prices each chunk of --chunk rows (200 by default) before it starts it and stops before one that would pass the cap.
  • Each finished chunk is written at once, and a second run skips every row already in the output, so a stopped run resumes where it ended.
  • A 429 or 503 is sent again after its Retry-After; an empty balance (402) or a refused key stops the run with the rows saved.
  • With no SPECSTREAM_API_KEY it stops before the first call.

Test

python -m unittest discover -s tests -v     # offline, against a local fake of the API with null and empty fields
python tests/live_check.py                  # live and free: both routes answer and ask for a key

Links

License

MIT

About

Async CSV enrichment of companies and domains from the live web: website, description, emails and social profiles with sources, via SpecStream fast search ($1/1K) and Extract ($0.80/1K). Stdlib only.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages