Exemplo n.º 1
0
def extract(response):
    tree = parse(response)
    return text(tree.xpath('//h1/text()'))
Exemplo n.º 2
0
def test_text_html_comment():
    tree = html.fromstring('<html><!-- comment --></html>')
    assert [t for t in e.text(tree)] == []
Exemplo n.º 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"]'))
Exemplo n.º 4
0
def region(response):
    return text(xpath('//dd[@id="region"]')(response))
Exemplo n.º 5
0
def name(response):
    return text(xpath('//h1')(response))
Exemplo n.º 6
0
def country(response):
    return text(xpath('//dd[@id="country"]')(response))
Exemplo n.º 7
0
def test_text_html_comment():
    tree = html.fromstring('<html><!-- comment --></html>')
    assert [t for t in e.text(tree)] == []
Exemplo n.º 8
0
def name(response):
    return text(xpath('//h1')(response))
Exemplo n.º 9
0
def region(response):
    return text(xpath('//dd[@id="region"]')(response))
Exemplo n.º 10
0
def country(response):
    return text(xpath('//dd[@id="country"]')(response))