parse_iframe_segments_css (selector_parser)

pydoll · scraping, css-parser, iframe-traversal, selector-parsing, automation

Splits a CSS selector at iframe boundaries to enable cross-iframe element traversal, returning segment tuples for stepwise lookup.

    def parse_iframe_segments_css(expression: str) -> list[tuple[By, str]]:
        """
        Split a CSS selector at iframe boundaries for cross-iframe traversal.

        Tokenises the selector into compound selectors separated by
        combinators (space, ``>``, ``+``, ``~``), respecting quoted strings,
        brackets and parentheses. Compounds whose tag name is ``iframe``
        (case-insensitive) act as split points.

        Args:
            expression: Raw CSS selector.

        Returns:
            List of ``(By.CSS_SELECTOR, segment)`` tuples.  A single-element
            list when no iframe crossing is detected.
        """
        css_compounds = SelectorParser._tokenize_css_compounds(expression)
        if not css_compounds:
            return [(By.CSS_SELECTOR, expres

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key