python+chromedriver实现后端服务器后台使用浏览器核心无损呈现svg,再进行截图
python代码如下:
#!/usr/bin/python3
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import argparse
import re
import requests
from os import path
parser = argparse.ArgumentParser(description="svgtopng")
parser.add_argument("svgfilepath",help="The content of svgfile")
parser.add_argument("pngFileName",help="The content of svgfile")
parser.add_argument("tempFilePath",help="The content of svgfile")
args = parser.parse_args()
fileSavePath =args.tempFilePath
#读取SVG内容
headers = {
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) "
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"}
response = requests.get(args.svgfilepath, headers=headers,timeout =4)
svgConten