ValueError: Unicode strings with encoding declaration are not supported.
Please use bytes input or XML fragments without declaration.
当我尝试解析这个网站时,它不起作用。
当我尝试序列化这个页面文本时,出现错误TypeError:类型'str'无法序列化
from lxml import html
source = 'http://games.chruker.dk/eve_online/item.php?type_id=814'
path = '//*[@id="top"]/table[1]/tbody/tr[1]/td[3]/table'
page = requests.get(source)
pagetext = page.text
parser = html.fromstring(pagetext)
result = parser.xpath(path)
print(result)
我希望你能提供一个类似于以下网站的需求表格: http://games.chruker.dk/eve_online/item.php?type_id=814
element = html.parse(source)
呢?html.parse
方法支持像source
变量中一样的URL作为输入。 - Martin Honnen