今天弄验证码的时候发现,验证码的图片的src竟然是下面的这么一个一串字符串,吓到,好像不可以http请求的,第一次见,就好尴尬,去网上搜索了一下,说是:
这是Data URI scheme。
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2NjIpLCBxdWFsaXR5ID0gOTAK/9sAQwADAgIDAgIDAwMDBAMDBAUIBQUEBAUKBwcGCAwKDAwLCgsLDQ4SEA0OEQ4LCxAWEBETFBUVFQwPFxgWFBgSFBUU/9sAQwEDBAQFBAUJBQUJFA0LDRQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU/8AAEQgAQADQAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8A57xdHqTafFJpsN7dPDI0ktrp2pQWFxOgjfCJNPa3MYJcpw0Yzj761mW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HXxXjsdQ1DRfHXw7nT7PqGoCOW82X0ShXcSvbQRYnSfe0z4MJYNWnRSsKxzOveBbLWtRTWrWSTR/EUcLQR6pahSzRNjfDPGwMdzA65R4ZldHR3UjDGs+xsrK21vT7fWLGX4cXM9lHbXHivwLpEV7od5cwSMyTXugwWqzQSTwAxySWk4QSeWdqqSF7aimBxWtQ+Ode8M6u3gLXvhz47SOyl1BNc0TxbZWctnY4jKXd3YXskb2uBKqOsjkxyAhhjbu7D4vf8E+LjQbu38QfDnUPG3jD4oaDrcM89vrN3b6S99ZIJN0+nyII33xuiFWEnqQpOAcrXvBXh/xU6vrOh6dqsiIY0kvLVJXRT2VmBI/CpPAviX4rfA3SIdE+HvivTNV8HW0rzWvg/xtp4vrK3dm3Hy51xOig5wgbALMeSxNKyvqFlfU4LVvjn4x+Ekep2viP4w/GbwRe63Yuv8AYviyO7a7jiJIzA1zC5ibPAlidWH98dvTf2dfBHijUvgz4MHieCGHxf8AEDxRf61LPcwGK/uIZTbwQ3F0Cob55EuZAejKwfksSe2i/bu+LOkaRFp+ufCiS/unlzda34P8WmJQh4PlW15FMwIGeNwGcYK1V8U/tSyx391qfw4+H3jW98eXUL20Hib4jXdnHBpWVZPOSKB5PNKjhV4HzZ5HDUuVWZSsupxHhb4X+LPE/wAU/i34p8G2+ifETT/EPjHUb2IaB4is2vYbUyu0TSQzPGEUbtnLhs5+Xbhmiudbu9LiifWfC3irQPMeOH/iZ+H7uJUleISiNpPLKB9hJK7sjB9K4zwv8BfC2j+ELfR7/TodSuWgMd7fYMct0zOJGLMpDEbwCAScbV9K9MtPEHjrTbgSWXxR8awRi2mtPIn1QXiGORyzZ+0pIS4zhZCd6jgMBThFxjZyi/VSg/nJOon20hHvreyz17W/H/L8yC3njuoI5onEkUih0cdGBGQakqCytI9Psre1hBEUEaxICcnaBgfyqek7Xdtiltqf/9k=
Data URI scheme是在RFC2397中定义的,目的是将一些小的数据,直接嵌入到网页中,从而不用再从外部文件载入。比如上面那串字符,其实是一张小图片,将这些字符复制黏贴到火狐的地址栏中并转到,就能看到它了,一张1X36的白灰png图片。
在上面的Data URI中,data表示取得数据的协定名称,image/png 是数据类型名称,base64 是数据的编码方法,逗号后面就是这个image/jpeg文件base64编码后的数据
目前,Data URI scheme支持的类型有:
data:,文本数据
data:text/plain,文本数据
data:text/html,HTML代码
data:text/html;base64,base64编码的HTML代码
data:text/css,CSS代码
data:text/css;base64,base64编码的CSS代码
data:text/javascript,Javascript代码
data:text/javascript;base64,base64编码的Javascript代码
data:image/gif;base64,base64编码的gif图片数据
data:image/png;base64,base64编码的png图片数据
data:image/jpeg;base64,base64编码的jpeg图片数据
data:image/x-icon;base64,base64编码的icon图片数据
重要的地方来了
其实逗号后面的那一串数据是图片的二进制的数据的base64进行加密的,所以要想得到图片,就必须进行解密。
以下是解密并且展示出来的图片:
code = url.encode('utf-8').replace('data:image/jpeg;base64,','')#print code
x =base64.b64decode(code)#print x
# i =Image.open(StringIO(x))
i.show()
这是还原为图片并且保存下来的:
imgdata=base64.b64decode(strs)
file=open('1.jpg','wb')
file.write(imgdata)
file.close()