热刺爬取——词云
今天完成了词云数据的完善,对每一个词都爬取了其相关的点赞数和分享数,另外在网上找了一些词云的可视化展示,在网上找了相关的echarts的js代码以及相关你的内容。
参考了网上的一些博客。找了一些资料最终完成了相关词云的可视化展示,但是还是有一些细节没做好。
源代码:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); %> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <link rel="stylesheet" href="./layui/css/layui.css" > <script type="text/javascript" src="./layui/layui.js"></script> <script type="text/javascript" src="js/echarts.min.js"></script> <script type="text/javascript" src="js/echarts-wordcloud.min.js"></script> <style> .span { font-size: 20px; font-family: FangSong; 仿宋; top: 5px; } </style> </head> <body> <% String data = (String) request.getAttribute("ciyundata"); %> <div id="conditionarea" align="center"> <div class="layui-form-item"> <div class="layui-inline"> <label class="layui-form-inline">分类规则</label> <select style="width:120px;height:36px;" name="interest" id="interest" lay-filter="aihao"> <option value="desc_likecount" selected="">点赞次数</option> <option value="desc_share">分享次数</option> </select> </div> <div class="layui-inline"> <label class="layui-form-label">范围</label> <div class="layui-input-inline" style="width: 100px;"> <input type="text" id="price_min" name="price_min" placeholder="¥" autocomplete="off" class="layui-input"> </div> <div class="layui-form-mid">-</div> <div class="layui-input-inline" style="width: 100px;"> <input type="text" id="price_max" name="price_max" placeholder="¥" autocomplete="off" class="layui-input"> </div> </div> <button type="button" class="layui-btn layui-btn-normal" style="top:-2px;" onclick="Show()">展示</button> </div> </div> <div id="main" style="width: 800px; height: 500px"></div> <script> function Show(){ var interest=document.getElementById("interest").value; var price_min=document.getElementById("price_min").value; var price_max=document.getElementById("price_max").value; var sql=price_max-price_min; var search="limit "+price_min+","+sql; var url="WordServle?method=showword&sql="+search+"&table="+interest; if(sql<=0)alert("范围输入错误"); else window.location.href = url; } var ciyundata = <%=data%> onload = function() { var data = { value : ciyundata, //词云形状图片base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ML7zGC3ikR3XMdG9lF7jCPtMHZkj5D69US5cr20Nc3fIAL5k+TK6Gpd+dMp0T75neGGbdlqd6ybQs8Zbpb/gx5U8C6Zl9nGRfM13RmmhZhDbT3/xdpg/n4Vx/7l1acH2mi4nXc21+T7AmWQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB4rn8BMx27OvTYQ/cAAAAASUVORK5CYII=" } var myChart = echarts.init(document.getElementById('main')); //温馨提示:image 选取有严格要求不可过大;,否则firefox不兼容 iconfont上面的图标可以 var maskImage = new Image(); maskImage.src = data.image maskImage.onload = function() { myChart.setOption({ backgroundColor : '#fff', tooltip : { show : false }, series : [ { type : 'wordCloud', gridSize : 1, sizeRange : [ 12, 55 ], rotationRange : [ -45, 0, 45, 90 ], maskImage : maskImage, textStyle : { normal : { color : function() { return 'rgb(' + Math.round(Math.random() * 255) + ', ' + Math.round(Math.random() * 255) + ', ' + Math.round(Math.random() * 255) + ')' } } }, left : 'center', top : 'center', // width: '96%', // height: '100%', right : null, bottom : null, // width: 300, // height: 200, // top: 20, data : data.value } ] }) } } </script> </body> </html>
今天完成了简单的展示,明天将完成信息的列表展示,以及做一些补充。
今天的效果图。(词云形状可以更改)。