示例#1
0
def find_tag_with_text(node: cssselect2.ElementWrapper, tag: str,
                       text: str) -> Generator[Any, str, None]:
    """
    Find all child elements with tag name, and return elements with
    specified text.
    """
    return (child_node.etree_element.tail for child_node in node.query_all(tag)
            if clean_whitespace(child_node.etree_element.text) == text)
示例#2
0
def course_codes(parent: ElementWrapper, selector: str) -> Generator[str, Any, None]:
    """
    Generate course code strings from elements in given node.

    :param parent:
    :param selector:
    :return:
    """
    query: ElementWrapper = parent.query_all(selector)
    children: Generator[str, Any, None] = (
        clean_whitespace(list_item_node.etree_element.text)
        for list_item_node in query
    )
    return children