验证码每次请求都会变解决方法

如果利用模拟浏览器等方式通过验证码会遇到验证码每次请求都会变,那么这样就不能直接请求获取到验证码数据了。

所以这里其实直接通过js下载图片就行了。

1
2
3
4
5
let c = document.createElement('canvas');let ctx = c.getContext('2d');
let img = document.querySelector('.mac_verify_img') // 获取验证码元素
c.height=img.naturalHeight;c.width=img.naturalWidth;
ctx.drawImage(img, 0, 0,img.naturalWidth, img.naturalHeight);
let base64String = c.toDataURL();

这里的base64String就是当前验证码的base64地址了

image-20230324104359504

作者

datehoer

发布于

2023-03-16

更新于

2023-10-19

许可协议

评论