Skip to content

Include iframe contents#92

Merged
c4software merged 3 commits into
c4software:masterfrom
marshvee:include-iframe-contents
Jul 24, 2026
Merged

Include iframe contents#92
c4software merged 3 commits into
c4software:masterfrom
marshvee:include-iframe-contents

Conversation

@marshvee

@marshvee marshvee commented May 2, 2024

Copy link
Copy Markdown
Contributor

Iframes are sometimes used to have parts of sites controlled by a CMS.

Here we add the option of inspecting the iframe's content and for any links that are to the site being indexed, having those included. It takes into account the tag, since if the base tag matches the site being indexed, then all relative URLs should be crawled.

If you want to enable this option, you can just add the flag:

python main.py --fetch-iframes

Resolves #90

@c4software c4software left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and tested locally against a small mock site (main domain + a "CMS" iframe on a different host declaring a matching <base href>, plus an unrelated third-party iframe with no <base> tag):

  • --fetch-iframes off (default): behavior is unchanged — only same-domain <a> links are crawled, iframe srcs are never fetched. Backward compatible.
  • --fetch-iframes on: the iframe pointing to the unrelated external domain is fetched once and correctly dropped (no matching <base>, so it's excluded from the sitemap and not crawled further). The iframe with a <base href> matching the target domain is correctly detected, and its relative links are resolved against that base and added to the crawl — exactly the behavior requested in #90.

Code looks solid: it's opt-in, respects existing --exclude/--skipext/robots.txt checks for iframe-discovered links, and doesn't change output for sites that don't use iframes. Left one minor whitespace nit inline (non-blocking).


Generated by Claude Code

Comment thread crawler.py
url_string = "<url><loc>"+self.htmlspecialchars(final_url)+"</loc>" + lastmod + image_list + "</url>"
self.url_strings_to_output.append(url_string)
# If the URL has a different domain than the site being indexed, this was reached through an iframe
# In this case: if the base tag matches the site being indexed, then all relative URLs should be crawled.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this comment line mixes 2 spaces with tabs before the # (the rest of the file uses tabs only). Doesn't break anything since comment-only lines don't affect Python's indentation, but worth a quick cleanup for consistency with the rest of the file.

Suggested change
# In this case: if the base tag matches the site being indexed, then all relative URLs should be crawled.
# In this case: if the base tag matches the site being indexed, then all relative URLs should be crawled.

Generated by Claude Code

@c4software
c4software merged commit 60d615c into c4software:master Jul 24, 2026
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.

iframe contents ignored

2 participants