예제 #1
0
파일: test_field.py 프로젝트: luyu344/ruia
def test_html_field():
    field_en = HtmlField(css_select="div.brand a")
    field_zh = HtmlField(css_select="div.brand p")
    assert (
        field_en.extract(html_etree=html_etree)
        == '<a href="https://github.com">Github</a>'
    )
    assert field_zh.extract(html_etree=html_etree) == "<p>你好</p>\n"
예제 #2
0
파일: test_field.py 프로젝트: fossabot/ruia
def test_html_field_with_many():
    field = HtmlField(css_select="a.test_link", many=True)
    values = field.extract(html_etree=html_etree)
    assert len(values) == 5
    assert values[0] == '<a class="test_link" href="https://github.com/howie6879/">hello1 github.</a>\n'
    assert values[4] == '<a class="test_link" href="https://github.com/howie6879/">hello5 github.</a>\n' \
                        '    Some text outside.\n'
예제 #3
0
def test_html_field():
    field = HtmlField(css_select="div.brand a")
    assert (field.extract(
        html_etree=html_etree) == '<a href="https://github.com">Github</a>')