Splits a CSS selector at iframe boundaries to enable cross-iframe element traversal, returning segment tuples for stepwise lookup.
# Source: https://github.com/autoscrape-labs/pydoll | License: MIT | Copyright 2025 AutoscrapeLabs
# Provided via justclaw.it.com; keep this notice with the code.
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
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key