[Python] How to click and loop through html with Selenium Webdriver/Python with no hyperlink

Discussão em 'Python' iniciado por Stack, Novembro 28, 2024.

  1. Stack

    Stack Membro Participativo

    I'm new to scraping and am trying to get the available apartments and their accompanying information from this website (https://sightmap.com/embed/rx1p8y12vd6). Logically, I'm trying to have selenium click through each floor and then pull the dynamic information from each floor (Apt Number, Rent, etc.). The carousel has all the floors in the below format:

    <li id="floor-item-42349" role="option" aria-selected="false" aria-label="Floor 21 selected, 1 of 19 stories. 2 Units available." tabindex="-1" class="css-1ge3v7g-itemStyles"><span class="primary-font css-1an6fko-floorStyles">21</span><span class="css-1cygnfi-countStyles"><span class="css-1gmg8q9-numberStyles">2</span><span class="css-1c0jwqn-unitLabelStyles">Units</span></span></li>


    Previously, I've seen solutions which have a href to click on which makes it possible, but I don't see where this could be. I'm not familiar with how aria-labels work so maybe this is the key?

    Below is what I am working with currently but the click doesn't seem to work.

    floors = wait.until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "#floor-vertical-select > li ")))
    for floor in floors:
    if floor.text != "0":
    print("Floor: " + floor.text)
    floor.click()

    Continue reading...

Compartilhe esta Página