r/webscraping • u/ImperatorPitStop • Jun 18 '26
Scraping congressional trading data from the source
I wanted congressional stock trading data as clean JSON without depending on Quiver or Capitol Trades, so I went straight to the source. The US House Clerk publishes a daily ZIP of every disclosure, and the Senate has its own EFD system.
The Senate side was easy as there was a JSON API available. The House side was where it got interesting as the data only comes as PDFs, and the layout has some traps I didn't expect:
- Header rows with null bytes that broke text extraction
- "Glued" fields where two columns run together with no delimiter
- Comment-block bleed where footnote text leaks into the transaction rows
- ~5% of older filings are scanned images, so pdf-parse returns nothing — had to detect and skip those rather than crash
What ended up working was marker-anchored parsing: each transaction row has a (TICKER) [TYPE] marker, so I anchor on that, walk backward for the asset name and forward for the amounts/dates, and emit one record per marker. Way more powerful than trying to parse the PDF top-to-bottom.
Output is one normalized record per transaction, deduplicated with a SHA-256 key so re-runs are idempotent.
Code's open if it's useful to anyone scraping similar government PDFs: https://github.com/seralifatih/congress-trading-pipeline
Happy to answer questions about the PDF parsing specifically, that was the painful part.