jeudi 11 août 2016

Web scraping with lxml and requests

I have a web page with hotels, where i want to get all the hotel names. I made a code following instructions from this page, but no success. My code is here:

from lxml import html
import requests

page = requests.get('web page url')
tree = html.fromstring(page.content)

hotel_name = tree.xpath('//span[@title="sr-hotel__name"]/text()')

print(hotel_name)

All I get is an empty list. Any help?




Aucun commentaire:

Enregistrer un commentaire