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