在做一个网站的自动登录,网站的验证码用了svg数据返回,现在打算将数据拿到后转图片再识别验证码
pip3 install svglib
import svglib from svglib.svglib import svg2rlg from reportlab.graphics import renderPDF, renderPM drawing = svg2rlg("img.svg") #renderPDF.drawToFile(drawing, "drawing.pdf") renderPM.drawToFile(drawing, "fdrawing.png", fmt="PNG") #renderPM.drawToFile(drawing, "drawing.jpg", fmt="JPG")
原文方法:http://www.tangkin.com/index.php/archives/svg2pngjpg.html