Can we automate to get individual image size(Kb) in a webpage/website using selenium. there is any tool/process is available to automate this process. I want to automate to get all images URL having more than 50kb in a webpage/website. Please give your suggestions on this.
Asked
Active
Viewed 475 times
-1
-
What you have tried so far? – Helping Hands Nov 24 '15 at 06:25
-
using developer tools==>Network – Chandra Shekar U Nov 24 '15 at 06:30
-
You can fetch the urls using selenium and then send a request to each of the urls using [`requests`](http://docs.python-requests.org) library and fetch the size of the image. – JRodDynamite Nov 24 '15 at 07:04
-
Can you please send me the hot code for this, that would be a great help for me... – Chandra Shekar U Nov 24 '15 at 11:49
1 Answers
0
To get an image size on the webpage, you could ask to server. i.e; use URLConnection class to represent a communication link between application and that URL.
URLConnection urlConnection = new URL(we.getAttribute("src")).openConnection();
size = urlConnection.getContentLength();
This should work well and check the condition which has more than 50kB and get those urls. Hope this code must helps you.

sp238
- 13
- 1
- 1
- 3