如何使用Python保存randonly生成的图像? [英] How to save a randonly generated image with Python?

查看:144
本文介绍了如何使用Python保存randonly生成的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在网站上解决验证码.

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

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

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

HTML代码包含对php生成的img的重定向.但是,如果我尝试遵循此链接,则php会生成一个新图像,验证码解决方案失败.

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.

我需要通过jpg保存此图像.图像不应更改.

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

推荐答案

图像更改是在服务器端进行的,如果需要此图像的副本,则需要在页面加载时保存该图像

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.

查看这些图像是JPEG的数据,这将从该链接下载图像,

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)

这篇关于如何使用Python保存randonly生成的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆