Skip to content

Collect PDF links from sitemap-driven spiders too#6

Open
MirjamOdile wants to merge 1 commit into
mainfrom
pr/01-sitemap-pdf-collection
Open

Collect PDF links from sitemap-driven spiders too#6
MirjamOdile wants to merge 1 commit into
mainfrom
pr/01-sitemap-pdf-collection

Conversation

@MirjamOdile

Copy link
Copy Markdown

Problem

PDF_MODE=links_only (the default) records every .pdf link on a crawled page
as a URL-only item — but the link-scan is wired only into the rule-based spider
(database_spider.py::parse_article). Sitemap-driven spiders — the majority of
a typical fleet — emit no PDF items at all, so any project relying on the
framework's PDF harvest silently collects zero PDFs from them.

Change

sitemap_spider.parse_article() gains the exact block database_spider has,
with source_label="sitemap_spider". The item shape is identical:
{url, title=<filename>, content: "", metadata_json: {content_type: "pdf", found_on: <linking page>}} — nothing is downloaded.

Verification

  • New unit test test_sitemap_links_only_yields_url_only_items exercises the
    real parse_article with an HtmlResponse: same-org + external link, item
    shape including found_on provenance and the source label.
  • Live: a USE_SITEMAP spider's first test crawl produced 21 PDF rows
    alongside 36 HTML articles with zero per-spider config.
  • Full unit suite green.

Notes

Known shared limitation (inherited from the rule-based spider, unchanged here):
pages routed to named callbacks don't get the PDF scan, and PDF_MODE=extract
still has no link-following path for sitemap spiders. A single post-processing
hook on yielded responses would remove the per-spider-type duplication —
follow-up material, out of scope for this fix.

PDF_MODE=links_only (the default) records every .pdf link on a crawled
page as a URL-only item — but the link-scan was wired only into the
rule-based spider (database_spider.parse_article). Sitemap-driven
spiders emitted no PDF items at all, so any project relying on the
framework's PDF harvest silently collected zero PDFs from them.

parse_article() in sitemap_spider gains the exact block database_spider
has, with source_label="sitemap_spider".

See docs/requests/12-sitemap-pdf-collection.md (ships with the quality
tool PR) for the full write-up.
@iRanadheer iRanadheer force-pushed the pr/01-sitemap-pdf-collection branch from b7ea136 to e9cf4c9 Compare July 10, 2026 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant