Tohak
Tohak

Reputation: 15

How to save a randonly generated image with Python?

I'm trying to solve a CAPTCHA on a website.

< img src="/kcap.php?PHPSESSID=iahvgmjcb93a0k7fqrf43sq9sk" >

Html-code contains a redirect to php-generated img. But, if i try to follow this link, the php generates a new image and the CAPTCHA solution fails.

I need to save this image by jpg. The image should not change.

Upvotes: 0

Views: 102

Answers (1)

User1010
User1010

Reputation: 819

The image changing is being done at the server side, if you need a copy of this image you will need to save the image at the point of the page loading.

Looking at the data these images are JPEG's, this will download the image from that link,

import urllib.request

local_filename, headers = urllib.request.urlretrieve("https://www.list-org.com/kcap.php?PHPSESSID=iahvgmjcb93a0k7fqrf43sq9sk")

print(local_filename)

Upvotes: 1

Related Questions