Commit bdcc2b8d by 高宇强

gyq

parent cc3afdef
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
</head> </head>
<body> <body>
<div id="68b4d14e3c5c4244bfdcb44255ea8778" style="width:900px; height:500px;"></div> <div id="3c558637439b48cd8376beb835f7d0b1" class="chart-container" style="width:900px; height:500px;"></div>
<script> <script>
var chart_68b4d14e3c5c4244bfdcb44255ea8778 = echarts.init( var chart_3c558637439b48cd8376beb835f7d0b1 = echarts.init(
document.getElementById('68b4d14e3c5c4244bfdcb44255ea8778'), 'white', {renderer: 'canvas'}); document.getElementById('3c558637439b48cd8376beb835f7d0b1'), 'white', {renderer: 'canvas'});
var option_68b4d14e3c5c4244bfdcb44255ea8778 = { var option_3c558637439b48cd8376beb835f7d0b1 = {
"animation": true, "animation": true,
"animationThreshold": 2000, "animationThreshold": 2000,
"animationDuration": 1000, "animationDuration": 1000,
...@@ -21,7 +21,9 @@ ...@@ -21,7 +21,9 @@
"animationEasingUpdate": "cubicOut", "animationEasingUpdate": "cubicOut",
"animationDelayUpdate": 0, "animationDelayUpdate": 0,
"color": [ "color": [
"#1E90FF", "#fd666d",
"#67e0e3",
"#37a2da",
"#c23531", "#c23531",
"#2f4554", "#2f4554",
"#61a0a8", "#61a0a8",
...@@ -50,13 +52,33 @@ ...@@ -50,13 +52,33 @@
"series": [ "series": [
{ {
"type": "bar", "type": "bar",
"data": [ "name": "\u53d1\u660e\u4e13\u5229",
153, "data": [],
119, "stack": "stack1",
100, "barCategoryGap": "20%",
84, "label": {
67 "show": true,
], "position": "top",
"margin": 8
}
},
{
"type": "bar",
"name": "\u65b0\u578b\u5b9e\u7528\u65b0\u578b",
"data": [],
"stack": "stack1",
"barCategoryGap": "20%",
"label": {
"show": true,
"position": "top",
"margin": 8
}
},
{
"type": "bar",
"name": "\u5916\u89c2\u8bbe\u8ba1",
"data": [],
"stack": "stack1",
"barCategoryGap": "20%", "barCategoryGap": "20%",
"label": { "label": {
"show": true, "show": true,
...@@ -68,10 +90,14 @@ ...@@ -68,10 +90,14 @@
"legend": [ "legend": [
{ {
"data": [ "data": [
"" "\u53d1\u660e\u4e13\u5229",
"\u65b0\u578b\u5b9e\u7528\u65b0\u578b",
"\u5916\u89c2\u8bbe\u8ba1"
], ],
"selected": { "selected": {
"": true "\u53d1\u660e\u4e13\u5229": true,
"\u65b0\u578b\u5b9e\u7528\u65b0\u578b": true,
"\u5916\u89c2\u8bbe\u8ba1": true
} }
} }
], ],
...@@ -106,14 +132,7 @@ ...@@ -106,14 +132,7 @@
"curveness": 0, "curveness": 0,
"type": "solid" "type": "solid"
} }
}, }
"data": [
"9",
"42",
"35",
"38",
"36"
]
} }
], ],
"yAxis": [ "yAxis": [
...@@ -135,11 +154,12 @@ ...@@ -135,11 +154,12 @@
"curveness": 0, "curveness": 0,
"type": "solid" "type": "solid"
} }
} },
"data": []
} }
] ]
}; };
chart_68b4d14e3c5c4244bfdcb44255ea8778.setOption(option_68b4d14e3c5c4244bfdcb44255ea8778); chart_3c558637439b48cd8376beb835f7d0b1.setOption(option_3c558637439b48cd8376beb835f7d0b1);
</script> </script>
</body> </body>
</html> </html>
#-*- encoding:utf-8 -*-
import requests
import json
url = "http://172.16.18.120:9999/patentdoc/api/createdoc"
headers = {'Content-Type':'application/json'}
data = {"mycompanyname":"华为技术有限公司"}
res = requests.post(url, data=json.dumps(data), headers=headers)#post请求
print(res.text)
\ No newline at end of file
from pyecharts.charts import Gauge,Pie,Line,Bar
from pyecharts.render import make_snapshot
from snapshot_selenium import snapshot
from pyecharts import options as opts
def charts(datalist,charttype,pngpath):
try:
img = None
if charttype == 1: #仪表盘
img = Gauge()
img.add("知产价值评估",[("", datalist[0]["value"])], axisline_opts=opts.AxisLineOpts(
linestyle_opts=opts.LineStyleOpts(
color=[(0.3, "#67e0e3"), (0.7, "#37a2da"), (1, "#fd666d")], width=30
)),label_opts=opts.LabelOpts(formatter="{value}"))
elif charttype == 2:#饼状图
img = Pie()
valuelist = []
for list in datalist:
valuelist.append((list["key"],list["value"]))
img.add("", valuelist, label_opts=opts.LabelOpts(formatter="{b}: {c}"))
elif charttype ==3:#折线图
img = Line()
keylist = []
valuelist = []
for list in datalist:
keylist.append(list["key"])
valuelist.append(list["value"])
img.add_xaxis(keylist)
img.add_yaxis("",valuelist,color= "#1E90FF")
elif charttype ==4:#柱状图
img = Bar()
keylist = []
valuelist = []
for list in datalist:
keylist.append(list["key"])
valuelist.append(list["value"])
img.add_xaxis(keylist)
img.add_yaxis("",valuelist,color= "#1E90FF")
if img:
make_snapshot(snapshot, img.render(), pngpath)
return True
else:
return False
except Exception as e1:
print(e1)
return False
# 下面一句的作用1是:运行本程序文件时执行什么操作
if __name__ == "__main__":
data1 = [{"key":"价值评价","value":55.9}]
charts(data1,1,"1.png")
name = ["2014", "2015", "2016", "2017", "2018", "2019"]
value = [100, 300, 250, 90, 150, 50]
data2 = [{"key":"运行","value":100},{"key":"2015","value":300},{"key":"2016","value":250},{"key":"2017","value":150},
{"key":"2018","value":200},{"key":"2019","value":90}]
charts(data2,2,"2.png")
charts(data2,3,"3.png")
charts(data2,4,"4.png")
charts(data2,5,"5.png")
print("over")
import fitz
import time
import re
import os
def pdf2pic(path, pic_path):
'''
# 从pdf中提取图片
:param path: pdf的路径
:param pic_path: 图片保存的路径
:return:
'''
t0 = time.clock()
# 使用正则表达式来查找图片
checkXO = r"/Type(?= */XObject)"
checkIM = r"/Subtype(?= */Image)"
# 打开pdf
doc = fitz.open(path)
# 图片计数
imgcount = 0
lenXREF = doc._getXrefLength()
# 打印PDF的信息
print("文件名:{}, 页数: {}, 对象: {}".format(path, len(doc), lenXREF - 1))
# 遍历每一个对象
for i in range(1, lenXREF):
# 定义对象字符串
text = doc.getObjectString(i)
isXObject = re.search(checkXO, text)
# 使用正则表达式查看是否是图片
isImage = re.search(checkIM, text)
# 如果不是对象也不是图片,则continue
if not isXObject or not isImage:
continue
imgcount += 1
# 根据索引生成图像
pix = fitz.Pixmap(doc, i)
# 根据pdf的路径生成图片的名称
new_name = path.replace('\\', '_') + "_img{}.png".format(imgcount)
new_name = new_name.replace(':', '')
# 如果pix.n<5,可以直接存为PNG
if pix.n < 5:
pix.writePNG(os.path.join(pic_path, new_name))
# 否则先转换CMYK
else:
pix0 = fitz.Pixmap(fitz.csRGB, pix)
pix0.writePNG(os.path.join(pic_path, new_name))
pix0 = None
# 释放资源
pix = None
t1 = time.clock()
print("运行时间:{}s".format(t1 - t0))
print("提取了{}张图片".format(imgcount))
if __name__=='__main__':
# pdf路径
path = 'aaa.pdf'
pic_path = '/root/business/creatdoc'
# 创建保存图片的文件夹
if os.path.exists(pic_path):
print("文件夹已存在,请重新创建新文件夹!")
raise SystemExit
else:
os.mkdir(pic_path)
m = pdf2pic(path, pic_path)
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument("--no-sandbox")
browser = webdriver.Chrome(chrome_options=chrome_options,
executable_path="/root/chromedriver")
url = "http://www.baidu.com"
browser.get(url)
print("su")
time.sleep(10)
browser.quit()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment