当前位置: 首页>>代码示例>>Python>>正文


Python dominic.DOM类代码示例

本文整理汇总了Python中dominic.DOM的典型用法代码示例。如果您正苦于以下问题:Python DOM类的具体用法?Python DOM怎么用?Python DOM使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DOM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: select_by_attribute_id

def select_by_attribute_id(context):
    "selecting by attribute (id)"
    dom = DOM(context.html)

    (body, ) = dom.find("[id=firstp]")
    assert that(body).is_a(Element)
    assert that(body.attribute['id']).equals("firstp")
开发者ID:eroh92,项目名称:dominic,代码行数:7,代码来源:test_selectors.py

示例2: select_html

def select_html(context):
    "selecting html"
    dom = DOM(context.html)

    html = dom.get("html")
    assert that(html).is_a(Element)
    assert that(html.attribute['id']).equals("html")
开发者ID:eroh92,项目名称:dominic,代码行数:7,代码来源:test_selectors.py

示例3: select_by_id

def select_by_id(context):
    "selecting by id"
    dom = DOM(context.html)

    body = dom.find("#firstp").first()
    assert that(body).is_a(Element)
    assert that(body.attribute['id']).equals("firstp")
开发者ID:eroh92,项目名称:dominic,代码行数:7,代码来源:test_selectors.py

示例4: text_return_the_text_within_element

def text_return_the_text_within_element(context):
    "Element().text() returns the text content"
    dom = DOM(context.html)

    p = dom.find("#the-only-paragraph").first()

    assert that(p.text()).equals("the only one in th whole damn thing!?")
开发者ID:eroh92,项目名称:dominic,代码行数:7,代码来源:test_manipulation.py

示例5: attr_retrieves_each_attribute_by_name

def attr_retrieves_each_attribute_by_name(context):
    "attr retrieves attributes each attribute by name"
    dom = DOM(context.html)

    ul = dom.find("#objects").first()

    assert that(ul.attr('id')).equals('objects')
    assert that(ul.attr('class')).equals('list no-bullets')
开发者ID:gabrielfalcao,项目名称:dominic,代码行数:8,代码来源:test_manipulation.py

示例6: select_by_class_with_many_classes

def select_by_class_with_many_classes(context):
    "selecting by many classes at once"
    dom = DOM(context.html)

    elements = dom.find("li.stuff.thing")
    assert that(elements).the_attribute('tag').equals('li')

    assert that(elements[0].attribute['id']).equals('house')
开发者ID:eroh92,项目名称:dominic,代码行数:8,代码来源:test_selectors.py

示例7: select_paragraphs

def select_paragraphs(context):
    "selecting paragraphs"
    dom = DOM(context.html)

    paragraphs = dom.find("p")

    assert that(paragraphs).is_a(ElementSet)
    assert paragraphs.length is 6
开发者ID:eroh92,项目名称:dominic,代码行数:8,代码来源:test_attributes.py

示例8: select_by_child

def select_by_child(context):
    "selecting by parent > child, mixing many kinds of selectors"
    dom = DOM(context.html)

    elements = dom.find(
        "ul#objects > li.geometry"
    )
    assert that(elements).in_each('tag').matches(['li', 'li'])
    assert that(elements).in_each("attribute['id']").matches(['ball', 'square'])
开发者ID:eroh92,项目名称:dominic,代码行数:9,代码来源:test_selectors.py

示例9: select_by_child_complex

def select_by_child_complex(context):
    "selecting by parent > child, mixing many kinds of selectors"
    dom = DOM(context.html)

    elements = dom.find(
        "div.ball.dog.square.house.puppet#like-this-one > ul#objects > li.geometry"
    )
    assert that(elements).in_each('tag').matches(['li', 'li'])
    assert that(elements).in_each("attribute['id']").matches(['ball', 'square'])
开发者ID:eroh92,项目名称:dominic,代码行数:9,代码来源:test_selectors.py

示例10: select_paragraphs

def select_paragraphs(context):
    "selecting paragraphs"
    dom = DOM(context.html)

    identifiers = ["firstp", "ap", "sndp", "en", "sap", "first"]
    paragraphs = dom.find("p")

    assert that(dom).is_a(DOM)
    assert that(paragraphs).in_each("attribute['id']").matches(identifiers)
开发者ID:eroh92,项目名称:dominic,代码行数:9,代码来源:test_selectors.py

示例11: select_by_class

def select_by_class(context):
    "selecting by class name"
    dom = DOM(context.html)

    div = dom.find(".nothiddendiv").first()
    assert that(div).is_a(Element)
    assert that(div.attribute['id']).equals("nothiddendiv")
    assert that(div.attribute['style']).has("height:1px;")
    assert that(div.attribute['style']).has("background:white;")
开发者ID:eroh92,项目名称:dominic,代码行数:9,代码来源:test_selectors.py

示例12: html_return_the_html_string

def html_return_the_html_string(context):
    "Element().html() returns the html string"
    dom = DOM(context.html)

    p = dom.find("#the-only-paragraph").first()

    assert that(p.html()).equals(
        '<p id="the-only-paragraph">the only one in th whole damn thing!?</p>'
    )
开发者ID:eroh92,项目名称:dominic,代码行数:9,代码来源:test_manipulation.py

示例13: select_by_attribute_ends_with_with_quotes

def select_by_attribute_ends_with_with_quotes(context):
    "selecting attribute that ends with certain value with quotes"
    dom = DOM(context.html)

    elements = dom.find("ul#packages > li[id$=\"nd\"]")
    assert that(elements).in_each("attribute['id']").matches(
        [
            'java island',
        ]
    )
开发者ID:gabrielfalcao,项目名称:dominic,代码行数:10,代码来源:test_selectors.py

示例14: first_returns_the_first

def first_returns_the_first(context):
    "selecting all childs of some element"
    dom = DOM(context.html)

    elements = dom.find("#objects li")

    p = elements.first()
    assert that(p).is_a(Element)
    assert that(p.tag).equals("li")
    assert that(p.attribute['id']).equals("ball")
    assert that(p.text()).equals("to kick")
开发者ID:eroh92,项目名称:dominic,代码行数:11,代码来源:test_manipulation.py

示例15: last_returns_the_last

def last_returns_the_last(context):
    "selecting all childs of some element"
    dom = DOM(context.html)

    elements = dom.find("#objects li")

    p = elements.last()
    assert that(p).is_a(Element)
    assert that(p.tag).equals("li")
    assert that(p.attribute['id']).equals("puppet")
    assert that(p.text()).equals("to care with")
开发者ID:eroh92,项目名称:dominic,代码行数:11,代码来源:test_manipulation.py


注:本文中的dominic.DOM类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。