0

How can I get the URL from this output of Selenium in Python?

<div style="z-index: 999; overflow: hidden; background-position: 0px 0px; text-align: center; background-color: rgb(255, 255, 255); width: 480px; height: 672.172px; float: left; background-size: 1054px 1476px; display: none; border: 0px solid rgb(136, 136, 136); background-repeat: no-repeat; position: absolute; background-image: url(&quot;https://photo.venus.com/im/19230307.jpg?preset=zoom&quot;);" class="zoomWindow">&nbsp;</div>

I got the above output from the following command line:

driver.find_element_by_class_name('zoomWindowContainer')

1 Answer 1

1

Firstly, get style atribute by:

div = driver.find_element_by_class_name('zoomWindow')
style = div.get_attribute("style") # str

Then, using regex to find url from style:

import re
urls = re.findall(r"https?://.+\.jpg", style) # list
print (urls[0])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.