selenium

driver.find_elements returns empty list (python)

I'm trying to get images from a duckduckgo search, this is my function currently

def search(query):
    driver.get(f"https://duckduckgo.com/?q={query}&iax=images&ia=images")
    res = driver.find_elements(By.CLASS_NAME, "tile--img__img")
    while True:
        logger.debug(res)
        if len(res) == 0:
            time.sleep(1)
        else:
            break
            logger.info("Results pulled")

But no matter how long it waits, res always returns empty, and when I tried to do the same with find_element I got a nonexistent element error.

Inspect element on one of the images:

2
0
Comments 0