I want to scrape some hotel information from Booking.com. The website provides some hotel informations, in this particular case, how many rooms are still available. The followin
Welcome to SO. Here is the simple approach to get the number of vacant rooms.
# get all the vacant room elements
rooms = driver.find_elements_by_xpath("//span[@class='only_x_left sr_rooms_left_wrap ']")
for room in rooms:
# get the number of elements
print(room.get_attribute('data-x-left-count'))
Assuming that attribute is only associated with rooms left you can simply use attribute selector
rooms_left = [item.get_attribute('data-x-left-count') for item in driver.find_elements_by_css_selector("[data-x-left-count]")]