ImportError:无法导入名称' html'

时间:2015-01-12 06:48:14

标签: python-3.4

我运行这个python代码,并使用以下命令在Windows上导入lxml库:

Path > install setup.py

已成功安装。

代码是:

from lxml import html
import requests
page = requests.get('http://econpy.pythonanywhere.com/ex/001.html')
tree = html.fromstring(page.text)

#This will create a list of buyers:
buyers = tree.xpath('//div[@title="buyer-name"]/text()')

#This will create a list of prices
prices = tree.xpath('//span[@class="item-price"]/text()')
print ('Buyers: ', buyers)
print ('Prices: ', prices)

但是当我运行此代码时,会发生以下错误:

ImportError: cannot import name 'html'

1 个答案:

答案 0 :(得分:0)

您需要安装html包...检查此网址

  

https://pypi.python.org/pypi/html/