0

I'm trying to download automatically an image from a web page using python.

Let's be a bit more explicit :

I have a url in which I know there is only one tag. I would like to extract the url in the src="" from this tag.

I already know how to download an image when I got the path of the image like this : "http://abcde.com/path/to/the/image.jpg" but I would like to know if there is a way to get the path to download it after. (I only have the url of the page, not the file)

I'm using python 3 and sreached for this but didn't find something that could help me for the moment. Can anyone of you guys could help me ? Thanks !

1 Answers1

0

You can replace the parameters as you see fit, i guessed this is what you needed. You can add a for loop on the elements as needed or use the find_element_by_tag_name() if you only have one element

from selenium import webdriver    
driver = webdriver.Chrome()
elements = driver.find_elements_by_tag_name('tag_name')[0]
url = elements.get_attribute('src')
Ben Moskovitch
  • 156
  • 2
  • 4
  • find_elements_by_tqg_nqme was the thing I was seraching for I think and can't find it by myself on selenium doc, thanks ! (there is just missing the driver.get("http://websiteURL.com") but that's perfect ! – Louis FELDMAR Jul 07 '20 at 00:41