2017-1-6 python lxml报错

使用Xpath的时候报错

File "src/lxml/lxml.etree.pyx", line 3161, in lxml.etree.HTML (src/lxml/lxml.etree.c:78444)

  1. 使用.content保存二进制格式的
  2. 解析的时候转换一下
html = bytes(bytearray(html, encoding='utf-8'))
selector = etree.HTML(html)

你可能感兴趣的:(2017-1-6 python lxml报错)