Olivea
Olivea

Reputation: 61

Getting image size of a specific CSS class using Selenium or PIL in Python

I want to calculate the size of some images in Python. But I'm trying to automate it to only find the sizes images of certain classes. I'm new to PIL. Is there a way to, after defining url, also define the CSS class/name/id?

When I did some search there was Selenium that had some functionality for finding CSS elements by id/class/name. But with that is there a way to "connect" the data(image) inside those tags to PIL in a way for them to work together?

Upvotes: 2

Views: 159

Answers (1)

Olivea
Olivea

Reputation: 61

Oops just answering my own question here, I could do this in Selenium:

img_height = driver.find_element_by_name("someName").value_of_css_property("height")
img_width = driver.find_element_by_name("someName").value_of_css_property("width")

and multiply.

Upvotes: 1

Related Questions