0

I am trying to extract text content from a XPath expression using the following code:

page = requests.get('https://www.momondo.com/flight-search/PHL-VCE/2019-06-19-flexible/2019-06-25-flexible?sort=price_a')
tree = html.fromstring(page.content)
price = tree.xpath('//span[@class="title price"]/text()')
print(price)

However, the printed result is just: []

Is there something I am doing wrong?

Brian
  • 53
  • 1
  • 5
  • 1
    It would be immensely useful if you could post the content you're trying to extract from... – Jack Fleeting May 20 '19 at 15:55
  • I've added the content I am trying to extract from now. page = requests.get('https://www.momondo.com/flight-search/PHL-VCE/2019-06-19-flexible/2019-06-25-flexible?sort=price_a') – Brian May 20 '19 at 16:52
  • This is a dynamically loaded page and requests is not able to handle it. Take a look (for example) at https://towardsdatascience.com/data-science-skills-web-scraping-javascript-using-python-97a29738353f – Jack Fleeting May 20 '19 at 17:15
  • Please see more information [here](https://stackoverflow.com/questions/39882645/how-to-grab-headers-in-python-selenium-webdriver) as well. – C. Peck May 21 '19 at 06:56

0 Answers0