Playwright / Selenium Scrapers vs CVM Filings API

Teams often ask about Playwright Selenium vs CVM API after a portal scraper fails in CI. Browser automation can click through the CVM site; apicvm replaces that path with authenticated HTTP for companies and filings in the corpus.

Failure modes of browser scrapers

  • DOM and anti-bot changes break selectors
  • Headless fleets need proxies, captchas, and ops time
  • Hard to map clicks to durable document IDs
  • Parallelism hits rate limits and IP blocks

API path

resolve ticker → list documents → download file / extract text
export APICVM_KEY='apicvm_...'
export APICVM_URL='https://apicvm.dev'

curl -H "Authorization: Bearer $APICVM_KEY" \
  "$APICVM_URL/v1/companies/resolve?query=PETR4&by=ticker"

curl -H "Authorization: Bearer $APICVM_KEY" \
  "$APICVM_URL/v1/documents?ticker=PETR4&type=DFP&year=2024&perPage=20"

When scrapers still appear

Situation Note
Document type not in apicvm corpus Lacuna — scraper does not fix missing ingestion
One-off manual download Portal UI is fine
Production product feature Prefer API

Related: Scraping CVM portal vs apicvm.

When to use each

Use Prefer
Stable ticker → PDF in an app apicvm
Exploring a portal screen interactively Browser
iPaaS HTML bots Fragile — see Zapier scrapers vs API

Migration checklist

  1. Replace “login + click download” with GET /v1/documents filters
  2. Persist document.id instead of temporary portal filenames
  3. Move PDF fetch to /v1/documents/:id/file
  4. Delete headless Chrome from CI once parity is verified on your ticker set

If a type/year is missing, open an ingestion gap — do not reintroduce Selenium as the default path.

Current limitations

  • apicvm only returns ingested documents — not “everything the portal HTML can see.”
  • No claim of official CVM endorsement.
  • Extraction remains async.

Next steps

Ready to integrate?

Get an API key and start querying Brazilian CVM filings programmatically.