Пример #1
0
def extract(response):
    tree = parse(response)
    return text(tree.xpath('//h1/text()'))
Пример #2
0
def test_text_html_comment():
    tree = html.fromstring('<html><!-- comment --></html>')
    assert [t for t in e.text(tree)] == []
Пример #3
0
def extract(response):
    tree = parse(response)
    yield "name", text(tree.xpath('//h1/text()'))
    yield "whoops", 1/0
    yield "country", text(tree.xpath('//dd[@id="country"]'))
    yield "region", text(tree.xpath('//dd[@id="region"]'))
Пример #4
0
def region(response):
    return text(xpath('//dd[@id="region"]')(response))
Пример #5
0
def name(response):
    return text(xpath('//h1')(response))
Пример #6
0
def country(response):
    return text(xpath('//dd[@id="country"]')(response))
Пример #7
0
def test_text_html_comment():
    tree = html.fromstring('<html><!-- comment --></html>')
    assert [t for t in e.text(tree)] == []
Пример #8
0
def name(response):
    return text(xpath('//h1')(response))
Пример #9
0
def region(response):
    return text(xpath('//dd[@id="region"]')(response))
Пример #10
0
def country(response):
    return text(xpath('//dd[@id="country"]')(response))