Я пытаюсь извлечь некоторые данные с сайта с помощью python. Я нашел (document, что точно соответствует моей проблемеHTML Скребок с Python, document_fromstring пуст
Но когда я запускаю предоставленный код
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
Я получаю сообщение об ошибке:.
File "C:\Python27\lib\site-packages\lxml\html\__init__.py", line 617, in document_fromstring
"Document is empty")
ParserError: Document is empty
Любой идею, что может быть проблема ?
print 'page.content' или сохранить его в файле, посмотреть, содержит ли файл HTML. – har07
попробуйте распечатать' page.text' – maazza