大家好,我是java1234_小鋒老師,最近寫了一套【NLP輿情分析】基于python微博輿情分析可視化系統(flask+pandas+echarts)視頻教程,持續更新中,計劃月底更新完,感謝支持。今天講解微博評論IP地圖可視化分析實現
視頻在線地址:
2026版【NLP輿情分析】基于python微博輿情分析可視化系統(flask+pandas+echarts+爬蟲) 視頻教程 (火爆連載更新中..)_嗶哩嗶哩_bilibili
課程簡介:
??
本課程采用主流的Python技術棧實現,Mysql8數據庫,Flask后端,Pandas數據分析,前端可視化圖表采用echarts,以及requests庫,snowNLP進行情感分析,詞頻統計,包括大量的數據統計及分析技巧。
實現了,用戶登錄,注冊,爬取微博帖子和評論信息,進行了熱詞統計以及輿情分析,以及基于echarts實現了數據可視化,包括微博文章分析,微博IP分析,微博評論分析,微博輿情分析。最后也基于wordcloud庫實現了詞云圖,包括微博內容詞云圖,微博評論詞云圖,微博評論用戶詞云圖等功能。
微博評論IP地圖可視化分析實現
同理,我們在ipDataAnalysis方法里實現下評論IP代碼:
cityDic2 = {} ?# 微博評論作者IPcommentList = commentDao.getAllComment()for comment in commentList:if comment[3]:for city in cityList:if city['province'].find(comment[3]) != -1:if cityDic2.get(city['province'], -1) == -1:cityDic2[city['province']] = 1else:cityDic2[city['province']] += 1commentCityDicList = [{'name': x[0],'value': x[1]} for x in cityDic2.items()]
?return render_template('ipDataAnalysis.html',articleCityDicList=articleCityDicList,commentCityDicList=commentCityDicList)
前端再實現下評論IP圖表代碼:
<script>
?function formatValue(value) {if (value) {return value} else {return 0}}
?var chartDom = document.getElementById('plMain');var myChart = echarts.init(chartDom);var option;
?option = {title: {text: '評論作者IP發布地址地圖',left: 'center',textStyle: {color: '#333',fontWeight: "bold"}},tooltip: {trigger: 'item',formatter: function (params) {return params.name + '<br>評論發布個數:' + formatValue(params.value) + ' 個'}},visualMap: {min: 0,max: 250,text: ['高', '低'],realtime: true,calculable: true,inRange: {color: ['orange', 'red']}},series: [{type: 'map',map: 'china',label: {normal: {show: true,color: "white",fontSize: "12"},},emphasis: {label: {show: true}},data:{{ commentCityDicList | tojson }},
?itemStyle: {normal: {areaColor: "skyblue",borderColor: "#fff"},emphasis: {areaColor: "#2B91B7"}},zoom: 1.4,roam: true}]};
?option && myChart.setOption(option);
?</script>