开发者

How to get the URL Image which is displyed by script

开发者 https://www.devze.com 2022-12-12 23:25 出处:网络
When I view the source of page, I do not find the image src. but the image is displayed on the page. This image is generated by some server side code.

When I view the source of page, I do not find the image src. but the image is displayed on the page. This image is generated by some server side code.

I am using the selenium for testing. I want to download this image for verification/comparison.

How to 开发者_C百科get that image using python?


You need to step through the Javascript on that page which might be calling some server-side code to generate that image (e.g. a Captcha image). Using the tools-> page info-> media in Firefox also gives you images on the page that the browser knows about. This post for example gives me https://stackoverflow.com/posts/1838047/ivc/44ca as an image. That clearly points to some server side code.


If you aren't seeing an actual image tag in the HTML, your next step would seem to be figuring out how its being displayed.

The first place I'd suggest looking is in the .css files for this page. Images can actually be embedded using CSS, and this seems like the next likely option after being in the HTML code itself.

If it isn't in there, you may be dealing with some form of technique deliberately intended to prevent you from being able to download the image with a script. This may use obfuscated JavaScript or something similar and I wouldn't expect people to be able to give you an easy solution to bypass it (since it was carefully designed to resist exactly that).


if you just want to download the image, theres two strategies you can try:

  1. use a something like Firebug or Chrome developer tools. right click the element in question, click "inspect element", and look at the css properties of the element. if you look around, you should find something like background-image style or maybe just a normal tag. then you'll have the url to the image.

  2. use a something like Firebug or Chrome developer tools: look in the "resources" tab, and look for image files that show up.

0

精彩评论

暂无评论...
验证码 换一张
取 消