0

I am trying to get the price from the website. Can anyone please find the error in my code?

import requests
from bs4 import BeautifulSoup

def priceTracker():
    url = ' https://www.britishairways.com/travel/book/public/en_gb/flightList?onds=LGW-AMS_2022-3-11&ad=1&yad=0&ch=0&inf=0&cabin=M&flex=LOWEST&usedChangeSearch=true'
    response = requests.get(url)
    soup = BeautifulSoup(response.text,'lxml')
    #print(soup.prettify)
    price = soup.find(class_=" heading-sm ng-tns-c70-4 ng-star-inserted").next_sibling
    #print(soup) test if soup working properly
    print(price)
    
while True:
  priceTracker()

I have attached the DOM screen. Dom Screen

  • Are you sure you have a correct date for that url it's popping up empty. – Arundeep Chohan Feb 17 '22 at 02:03
  • @ArundeepChohan Thank you for your respond. I have attached the DOM screen of the price. I have updated the url (in case the url does not work, to get the url you go to the main website and press the search button) – GoogleTagger Feb 18 '22 at 07:56

0 Answers0