from lxml import html
import requests
page = requests.get('http://econpy.pythonanywhere.com/ex/001.html')
tree = html.fromstring(page.content)
#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)
当我运行代码时,我收到以下错误
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35- 32\webscrape.py", line 1, in <module>
from lxml import html
ImportError:没有名为'lxml'的模块
虽然,当我尝试通过命令提示符安装它时,我得到以下结果。
Requirements already satisfied<-- to upgrade>c:\users\admin\anaconda3\lib\site-packages
我使用的是Windows 8。 我已经尝试了一切,但我无法解决问题。