Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14011

Is it possible to download image from website via Selenium (Python) in case is generated dynamically from server?

$
0
0

I found out in Web Inspector tool image on one site (domain is just for example)https://somesite.com/asd/photo.pl?num=10 which is not part of website but is probably generated dynamically from server.
I would like to ask if is possible to download it via selenium in python.
I tried this but it does not works. I think it is not possible by this way due to server site like I meantioned.

from selenium import webdriverimport urllib.requestimport shutilimport timeimport requestsdriver = webdriver.Firefox()driver.get("https://somesite.com/")img = driver.find_element(By.XPATH, '/html/body/div[2]/div/div[1]/a/img')img_url = img.get_attribute('src')response = requests.get(img_url)with open("saved_image.jpg", "wb") as file:    file.write(response.content)

Viewing all articles
Browse latest Browse all 14011

Trending Articles