Include iframe contents#92
Conversation
c4software
left a comment
There was a problem hiding this comment.
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-iframesoff (default): behavior is unchanged — only same-domain<a>links are crawled, iframesrcs are never fetched. Backward compatible.--fetch-iframeson: 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
| 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. |
There was a problem hiding this comment.
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.
| # 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
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:
Resolves #90