[免費]基于Python的網易云音樂熱門歌單可視化大屏項目(flask+pandas+echarts+request庫)【論文+源碼+SQL腳本】

大家好,我是python222_小鋒老師,看到一個不錯的基于Python的網易云音樂熱門歌單可視化大屏項目(flask+pandas+echarts+request庫),分享下哈。

項目視頻演示

【免費】基于Python的網易云音樂熱門歌單可視化大屏項目(flask+pandas+echarts+爬蟲) Python畢業設計_嗶哩嗶哩_bilibili

項目介紹

數字化時代帶動著整個社會的信息化發展,隨著數字媒體的不斷發展,現在通多媒體數字產品的內容越來越豐富,傳播影響力越來越強,以音樂為例,現在的音樂文化多樣、音樂資源也異常的豐富,在這種大數據的環境下,基于網易云音樂平臺的歌單數據,設計并實現了一個高度互動與視覺吸引力的數據可視化大屏項目。該項目通過挖掘網易云歌單的海量數據,包括但不限于歌單類型分布、熱門歌曲排行、用戶偏好分析、地域音樂風格差異等關鍵指標,為用戶、音樂創作者及平臺管理者提供直觀、全面的音樂生態洞察。采用可視化技術,如動態圖表、熱力圖、詞云等,將復雜的數據轉化為生動形象的視覺故事,不僅展現了音樂流行的趨勢與變遷,還揭示了用戶行為的深層規律。該數據可視化大屏不僅提升了音樂數據的價值密度,也為音樂行業的精準營銷、內容創作及用戶服務提供了有力的數據支持。

系統展示

部分代碼

# -*- coding: utf-8 -*-
import os
import re
import csv
import json
import time
import pymysql
import requests
from bs4 import BeautifulSoup
from multiprocessing import Pool# 老版本爬蟲響應速度慢,因為api接口(https://api.imjad.cn/)將在未來失效
# 開源方案 https://github.com/mixmoe/HibiAPI 的安裝文檔不詳細,但是提供了公開接口見'公開搭建實例'
# 于是找到 https://api.obfs.dev/docs#operation/playlist_api_netease_playlist_get
# 將現有接口替換下就實現了
# coder: SuccessKey# 請求頭
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36'
}# 歌單類型鏈接
type_url = "https://music.163.com/discover/playlist"# 連接數據庫
db = pymysql.connect(host="localhost",user="root",password="123456",port=3306,db="cloudmusic"
)cursor = db.cursor()"""獲取歌單類型"""def get_playlist_type(url):response = requests.get(url=url, headers=headers)html = response.textsoup = BeautifulSoup(html, 'lxml')types = [t.text for t in soup.select("a.s-fc1")][1:]# for t in types:#     print(t)return types"""獲取歌單id"""# CSV文件名,用于保存已爬取的歌單ID和類型
csv_filename = "playlist_ids.csv"# 獲取歌單ID并保存
def get_playlist_id(url):response = requests.get(url=url, headers=headers)html = response.textsoup = BeautifulSoup(html, 'lxml')# 獲取所有的歌單 IDids = [re.sub(r"\D+", "", i['href']) for i in soup.select("a.msk")]t = re.search('https.*cat=(.*)&limit', url).group(1)# 打印出所有的歌單ID和類型(調試用)print(f"獲取到的歌單ID: {ids}, 歌單類型: {t}")# 保存歌單ID和類型到CSV文件save_ids_to_csv(ids, t)# 保存ID和類型到CSV
def save_ids_to_csv(ids, t):# 打開文件并保存ID和類型with open(csv_filename, mode='a', newline='', encoding='utf-8') as file:writer = csv.writer(file)for id in ids:writer.writerow([id, t])  # 保存ID和類型到文件中print(f"已保存 {len(ids)} 個歌單ID 和類型到 {csv_filename}")# 讀取CSV文件中的已存在ID和類型
def load_ids_from_csv():existing_ids = {}  # 使用字典來存儲 ID 和類型的配對if os.path.exists(csv_filename):with open(csv_filename, mode='r', newline='', encoding='utf-8') as file:reader = csv.reader(file)for row in reader:existing_ids[row[0]] = row[1]  # ID作為key,類型作為valuereturn existing_ids"""獲取歌單信息"""def get_playlist_info(ids, t):# playlist_url = "https://api.imjad.cn/cloudmusic/?type=playlist&id={}"# playlist_url = "https://api.obfs.dev/api/netease/playlist?id={}"playlist_url = "https://hibi.moecube.com/api/netease/playlist?id={}"url = playlist_url.format(ids)print(url)response = requests.get(url=url, headers=headers)json_text = response.text# print(url)# print(response.text)json_playlist = json.loads(json_text)["playlist"]# 歌單ID、歌單名、歌單類型、標簽、創建時間、最后更新時間、播放量、收藏量、轉發量、評論數# 用戶名、性別、用戶類型、VIP類型、省份、城市playlistID = str(json_playlist["id"])name = json_playlist["name"]playlistType = ttags = "、".join(json_playlist["tags"])createTime = time.strftime("%Y-%m-%d", time.localtime(int(str(json_playlist["createTime"])[:-3])))updateTime = time.strftime("%Y-%m-%d", time.localtime(int(str(json_playlist["updateTime"])[:-3])))tracks_num = len(json_playlist["trackIds"])playCount = json_playlist["playCount"]subscribedCount = json_playlist["subscribedCount"]shareCount = json_playlist["shareCount"]commentCount = json_playlist["commentCount"]nickname = json_playlist['creator']['nickname']gender = str(json_playlist['creator']['gender'])userType = str(json_playlist['creator']['userType'])vipType = str(json_playlist['creator']['vipType'])province = str(json_playlist['creator']['province'])city = str(json_playlist['creator']['city'])# 匹配性別、省份、城市代碼if gender == '1':gender = '男'else:gender = '女'# 打開行政區代碼文件with open("country.csv", encoding="utf-8") as f:rows = csv.reader(f)for row in rows:if row[0] == province:province = row[1]if row[0] == city:city = row[1]if province == '香港特別行政區':city = '香港特別行政區'if province == '澳門特別行政區':city = '澳門特別行政區'if province == '臺灣省':city = '臺灣省'if province == str(json_playlist['creator']['province']):province = '海外'city = '海外'if city == str(json_playlist['creator']['city']):city = provinceplaylist = [playlistID, name, playlistType, tags, createTime, updateTime,tracks_num, playCount, subscribedCount, shareCount, commentCount,nickname, gender, userType, vipType, province, city]print(playlist)save_to_playlists(playlist)# def get_playlist_info(ids, t):
#     # playlist_url = "https://api.imjad.cn/cloudmusic/?type=playlist&id={}"
#     # playlist_url = "https://api.obfs.dev/api/netease/playlist?id={}"
#     playlist_url = "https://hibi.moecube.com/api/netease/playlist?id={}"
#     urls = [playlist_url.format(i) for i in ids]
#
#     for url in urls:
#         print(url)
#         try:
#             response = requests.get(url=url, headers=headers)
#             json_text = response.text
#             # print(url)
#             # print(response.text)
#             json_playlist = json.loads(json_text)["playlist"]
#         except:
#             continue
#
#         # 歌單ID、歌單名、歌單類型、標簽、創建時間、最后更新時間、播放量、收藏量、轉發量、評論數
#         # 用戶名、性別、用戶類型、VIP類型、省份、城市
#         playlistID = str(json_playlist["id"])
#         name = json_playlist["name"]
#         playlistType = t
#         tags = "、".join(json_playlist["tags"])
#         createTime = time.strftime("%Y-%m-%d", time.localtime(int(str(json_playlist["createTime"])[:-3])))
#         updateTime = time.strftime("%Y-%m-%d", time.localtime(int(str(json_playlist["updateTime"])[:-3])))
#         tracks_num = len(json_playlist["trackIds"])
#         playCount = json_playlist["playCount"]
#         subscribedCount = json_playlist["subscribedCount"]
#         shareCount = json_playlist["shareCount"]
#         commentCount = json_playlist["commentCount"]
#         nickname = json_playlist['creator']['nickname']
#         gender = str(json_playlist['creator']['gender'])
#         userType = str(json_playlist['creator']['userType'])
#         vipType = str(json_playlist['creator']['vipType'])
#         province = str(json_playlist['creator']['province'])
#         city = str(json_playlist['creator']['city'])
#
#         # 匹配性別、省份、城市代碼
#         if gender == '1':
#             gender = '男'
#         else:
#             gender = '女'
#
#         # 打開行政區代碼文件
#         with open("country.csv", encoding="utf-8") as f:
#             rows = csv.reader(f)
#
#             for row in rows:
#                 if row[0] == province:
#                     province = row[1]
#                 if row[0] == city:
#                     city = row[1]
#
#             if province == '香港特別行政區':
#                 city = '香港特別行政區'
#             if province == '澳門特別行政區':
#                 city = '澳門特別行政區'
#             if province == '臺灣省':
#                 city = '臺灣省'
#             if province == str(json_playlist['creator']['province']):
#                 province = '海外'
#                 city = '海外'
#             if city == str(json_playlist['creator']['city']):
#                 city = province
#
#         playlist = [playlistID, name, playlistType, tags, createTime, updateTime,
#                     tracks_num, playCount, subscribedCount, shareCount, commentCount,
#                     nickname, gender, userType, vipType, province, city]
#         print(playlist)
#         save_to_playlists(playlist)"""保存到數據庫"""
# 保存歌單信息到數據庫,如果已存在就更新
def save_to_playlists(l):sql = """INSERT INTO playlists(id, name, type, tags, create_time, update_time, tracks_num, play_count, subscribed_count, share_count, comment_count, nickname, gender, user_type, vip_type, province, city)VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)ON DUPLICATE KEY UPDATE name = VALUES(name), type = VALUES(type), tags = VALUES(tags), create_time = VALUES(create_time), update_time = VALUES(update_time), tracks_num = VALUES(tracks_num), play_count = VALUES(play_count), subscribed_count = VALUES(subscribed_count), share_count = VALUES(share_count), comment_count = VALUES(comment_count), nickname = VALUES(nickname), gender = VALUES(gender), user_type = VALUES(user_type), vip_type = VALUES(vip_type), province = VALUES(province), city = VALUES(city)"""try:cursor.execute(sql, (l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7], l[8], l[9], l[10],l[11], l[12], l[13], l[14], l[15], l[16]))db.commit()except Exception as e:db.rollback()print(f"Error: {e}")def main():types = get_playlist_type(type_url)urls = []for t in types:for i in range(37):url = "https://music.163.com/discover/playlist/?order=hot&cat={0}&limit=35&offset={1}".format(t, i * 35)print(url)urls.append(url)pool = Pool(10)for url in urls:pool.apply_async(get_playlist_id, args=(url,))pool.close()pool.join()def main2():# print(load_ids_from_csv())data = load_ids_from_csv()for k, v in data.items():# print(k, v)try:get_playlist_info(k, v)except:passif __name__ == "__main__":# main()main2()

源碼下載

鏈接:https://pan.baidu.com/s/1JcGAqWi2yBa12SlUHXQgeQ
提取碼:1234

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/bicheng/92968.shtml
繁體地址,請注明出處:http://hk.pswp.cn/bicheng/92968.shtml
英文地址,請注明出處:http://en.pswp.cn/bicheng/92968.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

AR 智能眼鏡:從入門到未來

從零看懂 AR 智能眼鏡:未來 10 年技術演進與新手入門指南 在這個數字技術飛速迭代的時代,AR 智能眼鏡正從科幻電影走進現實。從 2025 年重量不足 35 克的消費級產品,到 2030 年成為 “第二大腦” 的生活剛需,再到 2040 年進化為神經接口終端,AR 智能眼鏡的發展將重塑人類…

初識Vue2及MVVM理解

1、什么是Vue Vue是一款用于構建用戶界面的JavaScript框架。它基于標準HTML、CSS和JavaScript構建,并提供了一套聲明式的、組件化的編程模型,可以高效地開發用戶界面。 Vue.js是一套構建用戶界面的漸進式框架,采用自底向上增量開發的設計&…

Rust:專業級錯誤處理工具 thiserror 詳解

Rust:專業級錯誤處理工具 thiserror 詳解 thiserror 是 Rust 中用于高效定義自定義錯誤類型的庫,特別適合庫開發。相比 anyhow 的應用級錯誤處理,thiserror 提供更精確的錯誤控制,讓庫用戶能模式匹配具體錯誤。 📦 基…

Python網絡爬蟲(一) - 爬取靜態網頁

文章目錄一、靜態網頁概述1. 靜態網頁介紹2. 靜態網頁爬取技術Requests介紹二、安裝 Requests 庫三、發送請求并獲取響應1. 發送 GET 請求1.1 get() 方法介紹1.2 get() 方法簽名介紹1.3 get() 方法參數介紹1.4 示例:發送get請求2. 發送 POST 請求2.1 post() 方法介紹…

.NET/C# webapi框架下給swagger的api文檔中顯示注釋(可下載源碼)

bg&#xff1a;.NET/C#真的是越來越涼了。用的是.net9&#xff0c;創建完自帶一個天氣預報api拿來測試就行 1、在Controllers中弄多幾個&#xff0c;并寫上注釋 /// <summary> /// Post注釋 /// </summary> /// <returns></returns> [HttpPost] publ…

2508C++,檢測S模式

原文 可用Windows.System.Profile.WindowsIntegrityPolicy類檢測S模式. //C# using Windows.System.Profile; if (WindowsIntegrityPolicy.IsEnabled) {//系統在S模式if (WindowsIntegrityPolicy.CanDisable) {//系統在S模式,但可退出S模式suggestCompanion true;} else {//系…

Coding Exercising Day 9 of “Code Ideas Record“:StackQueue part 01

文章目錄1. Theoretical basisThe C standard library has multiple versions. To understand the implementation principles of stack and queue, we must know which STL version we are using.The stack and queue discussed next are data structures in *SGI STL*. Only …

Mysql數據倉庫備份腳本

Mysql數據倉庫備份腳本 #!/bin/bash# MySQL數據庫完整備份腳本 # 功能: 查詢所有數據庫 -> 分別導出 -> 壓縮打包# 配置區域 # MySQL連接信息 MYSQL_USER"root" MYSQL_PASSWORD"root" MYSQL_HOST"localhost" MYSQL_PORT"3306"…

基于嵌入式Linux RK3568 qt 車機系統開發

嵌入式系統、Qt/QML 與車機系統的發展趨勢分析 1. RK3568 開發板與 OpenGL ES 3 支持&#xff0c;為圖形應用打下堅實基礎 RK3568 是瑞芯微&#xff08;Rockchip&#xff09;推出的一款高性能、低功耗的64位處理器&#xff0c;廣泛用于工業控制、智能終端、嵌入式車載系統等領…

OceanBase架構設計

本文主要參考《大規模分布式存儲系統》 基本結構客戶端&#xff1a;發起請求。 RootServer&#xff1a;管理集群中的所有服務器&#xff0c;子表數據分布及副本管理&#xff0c;一般為一主一備&#xff0c;數據強同步。 UpdateServer&#xff1a;存儲增量變更數據&#xff0c;一…

[Element-plus]動態設置組件的語言

nuxt element-plus國際化vue element-plus國際化<template><div class"container"> <!-- <LangSwitcher />--><button click"toggle(zh-cn)">中文</button><button click"toggle(en)">English<…

【VS Code - Qt】如何基于Docker Linux配置Windows10下的VS Code,開發調試ARM 版的Qt應用程序?

如何在Windows 10上配置VS Code以開發和調試ARM版Qt應用程序。這需要設置一個基于Docker的Linux環境。首先&#xff0c;讓我們了解一下你的具體需求和環境&#xff1a;你有一個Qt項目&#xff08;看起來是醫學設備相關的設置程序&#xff09;目標平臺是ARM架構你希望在Windows …

linux常見故障系列文章 1-linux進程掛掉原因總結和排查思路

問題一 &#xff1a;運行時常見的進程崩潰原因 內存不足&#xff09; **0. 內存不足 內存不足&#xff08;OOM Killer&#xff09; 排查 OOM&#xff1a;free -h → dmesg → ps aux --sort-%mem 預防 OOM&#xff1a;限制關鍵進程內存、調整 OOM Killer 策略、增加 swap 長期優…

Spring Cloud Gateway 路由與過濾器實戰:轉發請求并添加自定義請求頭(最新版本)

前言 網關是什么?如果把你的系統比作一棟高端寫字樓,網關就是那位神通廣大的前臺小姐姐,笑容可掬地攔住不速之客,把貴賓引到豪華會議室,還會在你胸口貼上一枚醒目的“貴賓”標簽。它既懂禮數,又有原則,能過濾無效請求、轉發正確目標,還能在途中動點“小手腳”,比如加…

達夢數據庫慢SQL日志收集和分析

達夢數據庫慢SQL日志收集和分析 開啟SQL日志記錄 使用DMLOG工具分析SQLLOG DMLOG安裝配置 DMLOG分析日志 系統視圖V$LONG_EXEC_SQLS記錄了最近1000條執行時間超1s的sql。如果sql語句超長可能會被截斷,只能從sqllog里找完整的sql文本。 SELECT * FROM V$LONG_EXEC_SQLS ORDER …

一篇文章,帶你玩轉SparkCore

Spark Core 概念 前言 批處理&#xff08;有界數據&#xff09; ? 對靜態的、有限的數據集進行一次性處理&#xff0c;數據通常按固定周期&#xff08;如每小時、每天&#xff09;收集后統一計算。 特點&#xff1a; 高吞吐量&#xff0c;適合大規模數據。高延遲&#xff08;數…

VRRP技術

VRRP的概念及應用場景 VRRP&#xff08;虛擬路由冗余協議&#xff09;概念 VRRP&#xff08;Virtual Router Redundancy Protocol&#xff0c;虛擬路由冗余協議&#xff09;是一種路由容錯協議&#xff0c;用于在多個路由器之間提供網關冗余&#xff0c;確保當主路由器故障時&a…

表驅動法-靈活編程范式

表驅動法&#xff1a;從理論到實踐的靈活編程范式 一、為什么需要表驅動法&#xff1f; 在處理多分支邏輯&#xff08;如消息解析、命令分發&#xff09;時&#xff0c;傳統的 if-else 或 switch-case 存在明顯局限&#xff1a; 當分支數量龐大&#xff08;如成百上千條命令&am…

零基礎-動手學深度學習-10.2. 注意力匯聚:Nadaraya-Watson 核回歸

上節介紹了框架下的注意力機制的主要成分 圖10.1.3&#xff1a; 查詢&#xff08;自主提示&#xff09;和鍵&#xff08;非自主提示&#xff09;之間的交互形成了注意力匯聚&#xff1b; 注意力匯聚有選擇地聚合了值&#xff08;感官輸入&#xff09;以生成最終的輸出。 本節將…

nginx高新能web服務器

一、Nginx 概述和安裝 Nginx是免費的、開源的、高性能的HTTP和反向代理服務器、郵件代理服務器、以及TCP/UDP代理服務器。 Nginx 功能介紹 靜態的web資源服務器html&#xff0c;圖片&#xff0c;js&#xff0c;css&#xff0c;txt等靜態資源 http/https協議的反向代理 結合F…