Skip to content

Resolve scraped links against the final page URL - #412

Merged
Eigenwise merged 1 commit into
Eigenwise:mainfrom
Afloat16:scraper-absolute-links
Nov 17, 2026
Merged

Eigenwise merged 1 commit into
Eigenwise:mainfrom
Afloat16:scraper-absolute-links

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Problem

The webpage scraper exports relative hyperlinks and image sources unchanged. Once its Markdown is consumed outside the source document, those references no longer identify the source page's resources. Redirects and an HTML base element make reconstructing the original address from the input URL insufficient. The deep-research example contains the same implementation.

Changes

  • Retain the final response URL and resolve hyperlink/image references before selecting the main content.
  • Honor the first base href, resolving a relative base against the final response URL. Invalid bases and data:/javascript: bases fall back to that URL, following the HTML base-element rules.
  • Identify the final content host in metadata after a redirect.
  • Apply the same behavior to the Forge tool and the deep-research example. Link suppression continues to retain labels, images remain usable, and a malformed individual URL does not discard the article.

Validation

  • 38 real local HTTP cases run against both implementations. They cover relative paths, root/query/fragment/scheme-relative references, same-host and cross-host redirects, base selection and fallback, absolute URLs, data images, malformed links and include_links=False.
  • With the unchanged implementations, 34 regressions fail and four controls pass. With the fix, all 38 cases and 17 existing scraper tests pass.
  • Core suite: 1,152 passed, 14 skipped.
  • Full repository Black and Flake8 checks pass, as does git diff --check.

@Eigenwise
Eigenwise merged commit 74ba844 into Eigenwise:main Nov 17, 2026
3 checks passed
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.

2 participants