python
复制代码
import jieba # 分词
from matplotlib import pylab as plt # 绘图,数据可视化
from wordcloud import WordCloud # 词云
from PIL import Image # 图片处理
import numpy as np # 矩阵运算
from pymysql import *
import json
# wordCloud
# 所有词
def get_img(field,targetImgSrc,resImgSrc):
con = connect(host='localhost', user='root', password='root', database='boss', port=3306, charset='utf8mb4')
cursor = con.cursor()
sql = f"select {field} from jobinfo"
cursor.execute(sql)
data = cursor.fetchall()
text = ''
for i,item in enumerate(data):
text += item[0]
cursor.close()
con.close()
# 分词
cut = jieba.cut(text)
string = ' '.join(cut)
print(string)
# 图片
img = Image.open(targetImgSrc) # 打开遮罩图片
img_arr = np.array(img) # 将图片转化为列表
wc = WordCloud(
background_color='white',
mask=img_arr,
font_path='STHUPO.TTF'
)
wc.generate_from_text(string)
# 绘制图片
fig = plt.figure(1)
plt.imshow(wc)
plt.axis('off') # 不显示坐标轴
# 显示生成的词语图片
# plt.show()
# 输入词语图片到文件
plt.savefig(resImgSrc, dpi=500)
def get_addressCompanyTags_img(targetImgSrc,resImgSrc,addrress):
con = connect(host='localhost', user='root', password='root', database='boss', port=3306, charset='utf8mb4')
cursor = con.cursor()
sql = f"select companyTags from jobinfo where address = '{addrress}'"
cursor.execute(sql)
data = cursor.fetchall()
text = ''
for i, item in enumerate(data):
if item[0] != '无':
tags = json.loads(item[0])
print(tags)
for j in tags:
text = text + j
cursor.close()
con.close()
# 分词
cut = jieba.cut(text)
string = ' '.join(cut)
print(string)
# 图片
img = Image.open(targetImgSrc) # 打开遮罩图片
img_arr = np.array(img) # 将图片转化为列表
wc = WordCloud(
background_color='white',
mask=img_arr,
font_path='STHUPO.TTF'
)
wc.generate_from_text(string)
# 绘制图片
fig = plt.figure(1)
plt.imshow(wc)
plt.axis('off') # 不显示坐标轴
# 显示生成的词语图片
# plt.show()
# 输入词语图片到文件
plt.savefig(resImgSrc, dpi=500)
# get_img('companyTitle',r'.\static\2.jpg',r'.\static\companyTitle.jpg')
# get_img('summary',r'.\static\2.jpg',r'.\static\summary_cloud.jpg')
# get_img('casts',r'.\static\3.jpg',r'.\static\casts_cloud.jpg')
python
复制代码
/* iCheck plugin Minimal skin
----------------------------------- */
.icheckbox_minimal,
.iradio_minimal {
display: inline-block;
*display: inline;
vertical-align: middle;
margin: 0;
padding: 0;
width: 18px;
height: 18px;
background: url(../image/minimal.png) no-repeat;
border: none;
cursor: pointer;
}
.icheckbox_minimal {
background-position: 0 0;
}
.icheckbox_minimal.hover {
background-position: -20px 0;
}
.icheckbox_minimal.checked {
background-position: -40px 0;
}
.icheckbox_minimal.disabled {
background-position: -60px 0;
cursor: default;
}
.icheckbox_minimal.checked.disabled {
background-position: -80px 0;
}
.iradio_minimal {
background-position: -100px 0;
}
.iradio_minimal.hover {
background-position: -120px 0;
}
.iradio_minimal.checked {
background-position: -140px 0;
}
.iradio_minimal.disabled {
background-position: -160px 0;
cursor: default;
}
.iradio_minimal.checked.disabled {
background-position: -180px 0;
}
/* Retina support */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-moz-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 3/2),
only screen and (min-device-pixel-ratio: 1.5) {
.icheckbox_minimal,
.iradio_minimal {
background-image: url(../image/minimal@2x.png);
-webkit-background-size: 200px 20px;
background-size: 200px 20px;
}
}
/* red */
.icheckbox_minimal-red,
.iradio_minimal-red {
display: inline-block;
*display: inline;
vertical-align: middle;
margin: 0;
padding: 0;
width: 18px;
height: 18px;
background: url(../image/red.png) no-repeat;
border: none;
cursor: pointer;
}
.icheckbox_minimal-red {
background-position: 0 0;
}
.icheckbox_minimal-red.hover {
background-position: -20px 0;
}
.icheckbox_minimal-red.checked {
background-position: -40px 0;
}
.icheckbox_minimal-red.disabled {
background-position: -60px 0;
cursor: default;
}
.icheckbox_minimal-red.checked.disabled {
background-position: -80px 0;
}
.iradio_minimal-red {
background-position: -100px 0;
}
.iradio_minimal-red.hover {
background-position: -120px 0;
}
.iradio_minimal-red.checked {
background-position: -140px 0;
}
.iradio_minimal-red.disabled {
background-position: -160px 0;
cursor: default;
}
.iradio_minimal-red.checked.disabled {
background-position: -180px 0;
}
/* Retina support */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-moz-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
.icheckbox_minimal-red,
.iradio_minimal-red {
background-image: url(../image/red@2x.png);
-webkit-background-size: 200px 20px;
background-size: 200px 20px;
}
}
/* green */
.icheckbox_minimal-green,
.iradio_minimal-green {
display: inline-block;
*display: inline;
vertical-align: middle;
margin: 0;
padding: 0;
width: 18px;
height: 18px;
background: url(../image/green.png) no-repeat;
border: none;
cursor: pointer;
}
.icheckbox_minimal-green {
background-position: 0 0;
}
.icheckbox_minimal-green.hover {
background-position: -20px 0;
}
.icheckbox_minimal-green.checked {
background-position: -40px 0;
}
.icheckbox_minimal-green.disabled {
background-position: -60px 0;
cursor: default;
}
.icheckbox_minimal-green.checked.disabled {
background-position: -80px 0;
}
.iradio_minimal-green {
background-position: -100px 0;
}
.iradio_minimal-green.hover {
background-position: -120px 0;
}
.iradio_minimal-green.checked {
background-position: -140px 0;
}
.iradio_minimal-green.disabled {
background-position: -160px 0;
cursor: default;
}
.iradio_minimal-green.checked.disabled {
background-position: -180px 0;
}
/* Retina support */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-moz-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
.icheckbox_minimal-green,
.iradio_minimal-green {
background-image: url(../image/green@2x.png);
-webkit-background-size: 200px 20px;
background-size: 200px 20px;
}
}
/* blue */
.icheckbox_minimal-blue,
.iradio_minimal-blue {
display: inline-block;
*display: inline;
vertical-align: middle;
margin: 0;
padding: 0;
width: 18px;
height: 18px;
background: url(../image/blue.png) no-repeat;
border: none;
cursor: pointer;
}
.icheckbox_minimal-blue {
background-position: 0 0;
}
.icheckbox_minimal-blue.hover {
background-position: -20px 0;
}
.icheckbox_minimal-blue.checked {
background-position: -40px 0;
}
.icheckbox_minimal-blue.disabled {
background-position: -60px 0;
cursor: default;
}
.icheckbox_minimal-blue.checked.disabled {
background-position: -80px 0;
}
.iradio_minimal-blue {
background-position: -100px 0;
}
.iradio_minimal-blue.hover {
background-position: -120px 0;
}
.iradio_minimal-blue.checked {
background-position: -140px 0;
}
.iradio_minimal-blue.disabled {
background-position: -160px 0;
cursor: default;
}
.iradio_minimal-blue.checked.disabled {
background-position: -180px 0;
}
/* Retina support */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-moz-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 3/2),
only screen and (min-device-pixel-ratio: 1.5) {
.icheckbox_minimal-blue,
.iradio_minimal-blue {
background-image: url(../image/blue@2x.png);
-webkit-background-size: 200px 20px;
background-size: 200px 20px;
}
}
/* aero */
.icheckbox_minimal-aero,
.iradio_minimal-aero {
display: inline-block;
*display: inline;
vertical-align: middle;
margin: 0;
padding: 0;
width: 18px;
height: 18px;
background: url(../image/aero.png) no-repeat;
border: none;
cursor: pointer;
}
.icheckbox_minimal-aero {
background-position: 0 0;
}
.icheckbox_minimal-aero.hover {
background-position: -20px 0;
}
.icheckbox_minimal-aero.checked {
background-position: -40px 0;
}
.icheckbox_minimal-aero.disabled {
background-position: -60px 0;
cursor: default;
}
.icheckbox_minimal-aero.checked.disabled {
background-position: -80px 0;
}
.iradio_minimal-aero {
background-position: -100px 0;
}
.iradio_minimal-aero.hover {
background-position: -120px 0;
}
.iradio_minimal-aero.checked {
background-position: -140px 0;
}
.iradio_minimal-aero.disabled {
background-position: -160px 0;
cursor: default;
}
.iradio_minimal-aero.checked.disabled {
background-position: -180px 0;
}
/* Retina support */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-moz-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 3/2),
only screen and (min-device-pixel-ratio: 1.5) {
.icheckbox_minimal-aero,
.iradio_minimal-aero {
background-image: url(../image/aero@2x.png);
-webkit-background-size: 200px 20px;
background-size: 200px 20px;
}
}
/* grey */
.icheckbox_minimal-grey,
.iradio_minimal-grey {
display: inline-block;
*display: inline;
vertical-align: middle;
margin: 0;
padding: 0;
width: 18px;
height: 18px;
background: url(../image/grey.png) no-repeat;
border: none;
cursor: pointer;
}
.icheckbox_minimal-grey {
background-position: 0 0;
}
.icheckbox_minimal-grey.hover {
background-position: -20px 0;
}
.icheckbox_minimal-grey.checked {
background-position: -40px 0;
}
.icheckbox_minimal-grey.disabled {
background-position: -60px 0;
cursor: default;
}
.icheckbox_minimal-grey.checked.disabled {
background-position: -80px 0;
}
.iradio_minimal-grey {
background-position: -100px 0;
}
.iradio_minimal-grey.hover {
background-position: -120px 0;
}
.iradio_minimal-grey.checked {
background-position: -140px 0;
}
.iradio_minimal-grey.disabled {
background-position: -160px 0;
cursor: default;
}
.iradio_minimal-grey.checked.disabled {
background-position: -180px 0;
}
/* Retina support */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-moz-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
.icheckbox_minimal-grey,
.iradio_minimal-grey {
background-image: url(../image/grey@2x.png);
-webkit-background-size: 200px 20px;
background-size: 200px 20px;
}
}
/* orange */
.icheckbox_minimal-orange,
.iradio_minimal-orange {
display: inline-block;
*display: inline;
vertical-align: middle;
margin: 0;
padding: 0;
width: 18px;
height: 18px;
background: url(../image/orange.png) no-repeat;
border: none;
cursor: pointer;
}
.icheckbox_minimal-orange {
background-position: 0 0;
}
.icheckbox_minimal-orange.hover {
background-position: -20px 0;
}
.icheckbox_minimal-orange.checked {
background-position: -40px 0;
}
.icheckbox_minimal-orange.disabled {
background-position: -60px 0;
cursor: default;
}
.icheckbox_minimal-orange.checked.disabled {
background-position: -80px 0;
}
.iradio_minimal-orange {
background-position: -100px 0;
}
.iradio_minimal-orange.hover {
background-position: -120px 0;
}
.iradio_minimal-orange.checked {
background-position: -140px 0;
}
.iradio_minimal-orange.disabled {
background-position: -160px 0;
cursor: default;
}
.iradio_minimal-orange.checked.disabled {
background-position: -180px 0;
}
/* Retina support */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-moz-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
.icheckbox_minimal-orange,
.iradio_minimal-orange {
background-image: url(../image/orange@2x.png);
-webkit-background-size: 200px 20px;
background-size: 200px 20px;
}
}
/* yellow */
.icheckbox_minimal-yellow,
.iradio_minimal-yellow {
display: inline-block;
*display: inline;
vertical-align: middle;
margin: 0;
padding: 0;
width: 18px;
height: 18px;
background: url(../image/yellow.png) no-repeat;
border: none;
cursor: pointer;
}
.icheckbox_minimal-yellow {
background-position: 0 0;
}
.icheckbox_minimal-yellow.hover {
background-position: -20px 0;
}
.icheckbox_minimal-yellow.checked {
background-position: -40px 0;
}
.icheckbox_minimal-yellow.disabled {
background-position: -60px 0;
cursor: default;
}
.icheckbox_minimal-yellow.checked.disabled {
background-position: -80px 0;
}
.iradio_minimal-yellow {
background-position: -100px 0;
}
.iradio_minimal-yellow.hover {
background-position: -120px 0;
}
.iradio_minimal-yellow.checked {
background-position: -140px 0;
}
.iradio_minimal-yellow.disabled {
background-position: -160px 0;
cursor: default;
}
.iradio_minimal-yellow.checked.disabled {
background-position: -180px 0;
}
/* Retina support */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-moz-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
.icheckbox_minimal-yellow,
.iradio_minimal-yellow {
background-image: url(../image/yellow@2x.png);
-webkit-background-size: 200px 20px;
background-size: 200px 20px;
}
}
/* pink */
.icheckbox_minimal-pink,
.iradio_minimal-pink {
display: inline-block;
*display: inline;
vertical-align: middle;
margin: 0;
padding: 0;
width: 18px;
height: 18px;
background: url(../image/pink.png) no-repeat;
border: none;
cursor: pointer;
}
.icheckbox_minimal-pink {
background-position: 0 0;
}
.icheckbox_minimal-pink.hover {
background-position: -20px 0;
}
.icheckbox_minimal-pink.checked {
background-position: -40px 0;
}
.icheckbox_minimal-pink.disabled {
background-position: -60px 0;
cursor: default;
}
.icheckbox_minimal-pink.checked.disabled {
background-position: -80px 0;
}
.iradio_minimal-pink {
background-position: -100px 0;
}
.iradio_minimal-pink.hover {
background-position: -120px 0;
}
.iradio_minimal-pink.checked {
background-position: -140px 0;
}
.iradio_minimal-pink.disabled {
background-position: -160px 0;
cursor: default;
}
.iradio_minimal-pink.checked.disabled {
background-position: -180px 0;
}
/* Retina support */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-moz-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
.icheckbox_minimal-pink,
.iradio_minimal-pink {
background-image: url(../image/pink@2x.png);
-webkit-background-size: 200px 20px;
background-size: 200px 20px;
}
}
/* purple */
.icheckbox_minimal-purple,
.iradio_minimal-purple {
display: inline-block;
*display: inline;
vertical-align: middle;
margin: 0;
padding: 0;
width: 18px;
height: 18px;
background: url(../image/purple.png) no-repeat;
border: none;
cursor: pointer;
}
.icheckbox_minimal-purple {
background-position: 0 0;
}
.icheckbox_minimal-purple.hover {
background-position: -20px 0;
}
.icheckbox_minimal-purple.checked {
background-position: -40px 0;
}
.icheckbox_minimal-purple.disabled {
background-position: -60px 0;
cursor: default;
}
.icheckbox_minimal-purple.checked.disabled {
background-position: -80px 0;
}
.iradio_minimal-purple {
background-position: -100px 0;
}
.iradio_minimal-purple.hover {
background-position: -120px 0;
}
.iradio_minimal-purple.checked {
background-position: -140px 0;
}
.iradio_minimal-purple.disabled {
background-position: -160px 0;
cursor: default;
}
.iradio_minimal-purple.checked.disabled {
background-position: -180px 0;
}
/* Retina support */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-moz-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
.icheckbox_minimal-purple,
.iradio_minimal-purple {
background-image: url(../image/purple@2x.png);
-webkit-background-size: 200px 20px;
background-size: 200px 20px;
}
}