python抓取动态验证码,第几帧数的位置静态图片

文章资讯 2020-07-20 00:21:02

python抓取动态验证码,第几帧数的位置静态图片

一.代码+注解
import os
from PIL import Image
import requests
import io
def save_img():
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36'
}
url = '动图url'
resp = requests.get(url, headers=headers, verify=False)
code = io.BytesIO(resp.content)
im = Image.open(code)
im.seek(3) #第3帧的图片
im.save('1.png') #保存

save_img()