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"
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'
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>')