How to handle dynamic html tag class name?

35 Views Asked by At

It seems like they updated page after pandemic. It doesn't have class name like 'gws-flights-results__itinerary-price' like this post web scrapping google flight prices. How could we locate flight info if I want to use selenium or beautiful soap to scrap occationally. I used hard code class name, but this seems not scalable and may not work once flight airports are changed. Should I use other ways?

departure_airpot = tag.find('div',class_="ZHa2lc tdMWuf y52p7d").get_text()
    arrival_airport =tag.find('div',class_="FY5t7d tdMWuf y52p7d").get_text()
    departure_time = tag.find('div',class_="b0EVyb YMlIz y52p7d").get_text()
    arrival_time = tag.find('div',class_="b0EVyb YMlIz y52p7d").get_text()
    carrier = tag.find('div',class_="MX5RWe sSHqwe y52p7d").get_text()
    flight_num = tag.find('div',class_="Xsgmwe sI2Nye").get_text()
    flight_price= bs.find('div',class_="YMlIz FpEdX jLMuyc").get_text()

thanks a lot.

google flight search results

0

There are 0 best solutions below