How do you scrape PDFs from a website?
To scrape PDFs from a website, first collect the site's PDF URLs, then pass each link to a document parser that converts the file to structured text. The approach depends on how PDFs are served: directly linked .pdf files are straightforward to collect and parse, but embedded JavaScript viewers (like Scholarvox or FlipHTML5) load documents page by page, so the underlying file isn't reachable through a plain HTTP request and you need browser automation or a managed API instead.
| Source type | How PDFs are served | Approach |
|---|---|---|
| Direct links | Static .pdf URL in anchor tag | Map the site, collect URLs, pass to parser |
| Embedded viewer (JS) | Document loaded page by page via JS | Browser automation or managed API |
| Paginated viewer | Each page fetched as a separate request | Intercept requests or use API |
For directly linked PDFs, list the site's URLs, keep the ones ending in .pdf, then pass each one to a document parser. For embedded or paginated viewers, the underlying PDF URL may not be exposed at all, so tooling that drives a browser is needed to capture the actual document request.
With Firecrawl, /map lists a site's URLs in one call, and Firecrawl /scrape with document parsing turns each PDF URL into clean Markdown:
from firecrawl import Firecrawl
firecrawl = Firecrawl(api_key="fc-YOUR-API-KEY")
site = firecrawl.map("https://www.federalreserve.gov", search="pdf", limit=100)
pdf_urls = [link.url for link in site.links if link.url.lower().split("?")[0].endswith(".pdf")]
doc = firecrawl.scrape(pdf_urls[0], formats=["markdown"], parsers=[{"type": "pdf", "max_pages": 1}])
print(len(pdf_urls), doc.metadata.num_pages)On Oct 30, 2026 the map call returned 39 PDF links from federalreserve.gov, including FOMC minutes and Z.1 releases. Map costs 1 Firecrawl credit per call and PDF parsing 1 Firecrawl credit per page, so max_pages keeps the cost of a first pass predictable.
To find PDFs across the whole web rather than on one site, use a search API that filters by file type. Firecrawl /search takes categories=["pdf"] and returns only PDF results, and scrape_options parses each result in the same request:
from firecrawl import Firecrawl
firecrawl = Firecrawl(api_key="fc-YOUR-API-KEY")
results = firecrawl.search(
"attention is all you need transformer paper",
categories=["pdf"],
limit=3,
scrape_options={"formats": ["markdown"], "parsers": [{"type": "pdf", "max_pages": 1}]},
)
for result in results.web or []:
if getattr(result, "markdown", None):
print(result.metadata.url, len(result.markdown))That query returned three PDFs, from the NeurIPS proceedings, arXiv, and a university course page, each already in Markdown. For local or non-public documents, upload the file to Firecrawl /parse instead. For scanned PDFs, set mode to ocr on the PDF parser to run OCR across all pages. Both endpoints run on Fire-PDF, an engine that classifies pages automatically and reads text-based content without a GPU, averaging under 400ms per page for mixed documents. For a side-by-side comparison of PDF parsers for web scraping and AI workflows, including open-source options like Docling, Marker-PDF, and LlamaParse, see the dedicated guide. For a wider evaluation of managed document parsing APIs, see the best document parsing APIs guide.