hotelInfo()

Programming Language: Python 3 (As of Jan 2022)

Description


This function uses the location from the initial Travel() call. It connects to a Google search and gets all the hotel names then it concatenates the string at the end of the URL = "https://www.google.com/search?q=hotel" + self.location . Using Beautiful Soup, this function is able to parse the HTML code and it is coded to grab hotel names.

Parameters


self (None; however read description)

  Value of this must be a string

  self.location string needs to be a city or IATA Code.

Calling Example


        
            atlanta.hotelInfo()
        
        
    

Class Code


        
            def hotelInfo(self):
              URL = "https://www.google.com/search?q="+hotel_name
              headers = {'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0'}
              page = requests.get(URL)
              soup = BeautifulSoup(page.content,"html.parser")
              hotel_names = soup.find_all('div', class_ = 'BTPx6e bOYhNc')
              list_of_hotels = []
              for hotel in hotel_names:
                print (self.hotelSearch(hotel.text))
                list_of_hotels.append(self.hotelSearch(hotel.text))
              return (list_of_hotels)
        
        

Additional Information


Access to internet is needed to run this function when called.