[Python] Why does selenium do not download the images?

Discussão em 'Python' iniciado por Stack, Setembro 15, 2024.

  1. Stack

    Stack Membro Participativo

    In this code, im trying to download images from a page but it does not download them,i did it once but not anymore, i do not know what is bad here

    `from selenium import webdriver from selenium.webdriver.common.by import By import requests from PIL import Image from io import BytesIO

    driver = webdriver.Firefox()

    driver.get("https://anilist.co/search/anime?genres=Action&format=TV")

    image_element = driver.find_element(By.CSS_SELECTOR, "image.loaded")

    image_src = image_element.get_attribute("src")

    response = requests.get(image_src)

    if response.status_code == 200:

    image = Image.open(BytesIO(response.content))

    image.save("imagen-1.jpg")

    print("works")


    else: print("didnt work")

    driver.quit() `

    the class of the image is image loaded, i added the dot,

    I tried to put and remove the dot but is the same thing, i dont know what is happening

    Continue reading...

Compartilhe esta Página