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