【NLP舆情分析】基于python微博舆情分析可视化系统(flask+pandas+echarts) 视频教程 - 主页-微博点赞量Top6实现

大家好,我是java1234_小锋老师,最近写了一套【NLP舆情分析】基于python微博舆情分析可视化系统(flask+pandas+echarts)视频教程,持续更新中,计划月底更新完,感谢支持。今天讲解主页-微博点赞量Top6实现

视频在线地址:

2026版【NLP舆情分析】基于python微博舆情分析可视化系统(flask+pandas+echarts+爬虫) 视频教程 (火爆连载更新中..)_哔哩哔哩_bilibili

课程简介:

本课程采用主流的Python技术栈实现,Mysql8数据库,Flask后端,Pandas数据分析,前端可视化图表采用echarts,以及requests库,snowNLP进行情感分析,词频统计,包括大量的数据统计及分析技巧。

实现了,用户登录,注册,爬取微博帖子和评论信息,进行了热词统计以及舆情分析,以及基于echarts实现了数据可视化,包括微博文章分析,微博IP分析,微博评论分析,微博舆情分析。最后也基于wordcloud库实现了词云图,包括微博内容词云图,微博评论词云图,微博评论用户词云图等功能。

主页-微博点赞量Top6实现

我们再实现下微博点赞量Top6的功能。

articleDao实现getArticleTopZan方法:

复制代码
def getArticleTopZan():
    """
    获取点赞最高的6条帖子
    :return:
    """
    con = None
    try:
        con = dbUtil.getCon()
        cursor = con.cursor()
        sql = "select text_raw,attitudes_count from t_article order by attitudes_count DESC LIMIT 0,6"
        cursor.execute(sql)
        return cursor.fetchall()
    except Exception as e:
        print(e)
        con.rollback()
        return None
    finally:
        dbUtil.closeCon(con)

page.py的getHomePageData方法里调用dao方法获取数据,然后返回到前端。

复制代码
def getArticleTopZan():
    """
    获取点赞最高的6条帖子
    :return:
    """
    con = None
    try:
        con = dbUtil.getCon()
        cursor = con.cursor()
        sql = "select text_raw,attitudes_count from t_article order by attitudes_count DESC LIMIT 0,6"
        cursor.execute(sql)
        return cursor.fetchall()
    except Exception as e:
        print(e)
        con.rollback()
        return None
    finally:
        dbUtil.closeCon(con)

index.html 获取数据后,遍历dom追加:

复制代码
function truncateString(str, length) {
            if (str.length > length) {
                return str.slice(0, length) + '...';
            } else {
                return str;
            }
        }


        function getHomePageData() {
            $.get('/page/homePageData', function (result) {
                $('#totalArticle').text(result.totalArticle + '个')
                $('#topAuthor').text(result.topAuthor)
                $('#topRegion').text(result.topRegion)
                let topArticles = result.topArticles
                $("#topArticle").empty()
                for (let i = 0; i < topArticles.length; i++) {
                    const article = topArticles[i]
                    $("#topArticle").append('<li class="p-3 list-item d-flex justify-content-start align-items-center">' +
                        '<div class="list-style-detail ml-3 mr-2">' +
                        '<p class="mb-0">' + truncateString(article[0], 20) + '</p>' +
                        '</div>' +
                        '<div class="list-style-action d-flex justify-content-end ml-auto">' +
                        '<h6 class="font-weight-bold">' + article[1] + '👍</h6>' +
                        '</div>' +
                        '</li>')
                }
            })
        }
相关推荐
ERROR_LESS4 分钟前
【ADS-1】【python基础-2】基本语法与数据结构(列表、字典、集合)
python
2401_841495644 分钟前
【数据结构】基于Floyd算法的最短路径求解
java·数据结构·c++·python·算法··floyd
一晌小贪欢10 分钟前
Python爬虫第6课:Selenium自动化浏览器与动态内容抓取
爬虫·python·selenium·网络爬虫·python基础·python3·pathon爬虫
番石榴AI1 小时前
自己动手做一款ChatExcel数据分析系统,智能分析 Excel 数据
人工智能·python·数据挖掘·excel
星期天要睡觉1 小时前
深度学习——循环神经网络(RNN)
人工智能·python·rnn·深度学习·神经网络
Blossom.1181 小时前
把AI“撒”进农田:基于极值量化与状态机的1KB边缘灌溉决策树
人工智能·python·深度学习·算法·目标检测·决策树·机器学习
Red Car1 小时前
如何向文件夹内所有PDF增加水印
python·pdf
Q_Q5110082852 小时前
python+uniapp基于微信小程序团购系统
spring boot·python·微信小程序·django·uni-app·node.js·php
takashi_void2 小时前
本地实现斯坦福小镇(利用大语言模型使虚拟角色自主发展剧情)类似项目“Microverse”
人工智能·语言模型·自然语言处理·godot·游戏程序·斯坦福小镇
java1234_小锋2 小时前
TensorFlow2 Python深度学习 - 循环神经网络(LSTM)示例
python·rnn·深度学习·tensorflow2