最炫国漫《雾山五行》用 Python 了解一下到底有多优秀
看動(dòng)漫的小伙伴應(yīng)該知道最近出了一部神漫《霧山五行》:
1、極具特色的水墨畫(huà)風(fēng)和超燃的打斗場(chǎng)面廣受好評(píng)
2、首集播出不到 24 小時(shí)登頂 B 站熱搜第一,豆瓣開(kāi)分 9.5,
火爆程度可見(jiàn)一斑,就打斗場(chǎng)面而言,說(shuō)是最炫動(dòng)漫也不為過(guò),當(dāng)然唯一有一點(diǎn)不足之處就是集數(shù)有點(diǎn)少,只有 3 集。
下面放幾張動(dòng)圖,一起欣賞一下。
看過(guò)動(dòng)圖之后,是不是覺(jué)得我所說(shuō)的最炫動(dòng)漫,并非虛言,接下來(lái)我們爬取一些評(píng)論,了解一下大家對(duì)這部動(dòng)漫的看法,這里我們選取 B 站來(lái)爬取數(shù)據(jù)。
我們先來(lái)爬取 B 站彈幕數(shù)據(jù),動(dòng)漫鏈接為:https://www.bilibili.com/bangumi/play/ep331423,彈幕鏈接為:http://comment.bilibili.com/186803402.xml,爬取代碼如下:
import jieba import pandas as pd import requests from PIL import Image from bs4 import BeautifulSoup from wordcloud import WordCloudurl = "http://comment.bilibili.com/218796492.xml" req = requests.get(url) html = req.content html_doc = str(html, "utf-8") # 修改成utf-8 print(html_doc) # 解析 soup = BeautifulSoup(html_doc, "html.parser") results = soup.find_all('d') contents = [x.text for x in results] # 保存結(jié)果 dic = {"contents": contents} df = pd.DataFrame(dic) df["contents"].to_csv("bili.csv", encoding="utf-8", index=False)def jieba_():# 打開(kāi)評(píng)論數(shù)據(jù)文件content = open("bili.csv", "rb").read()# jieba 分詞word_list = jieba.cut(content)words = []# 過(guò)濾掉的詞# 需新建文本stopwordsstopwords = open("stopwords.txt", "r", encoding="utf-8").read().split("\n")[:-1]for word in word_list:if word not in stopwords:words.append(word)global word_cloud# 用逗號(hào)隔開(kāi)詞語(yǔ)word_cloud = ','.join(words)def cloud():# 打開(kāi)詞云背景圖cloud_mask = pd.np.array(Image.open("bg.png"))# 定義詞云的一些屬性wc = WordCloud(# 背景圖分割顏色為白色background_color='white',# 背景圖樣mask=cloud_mask,# 顯示最大詞數(shù)max_words=500,# 顯示中文font_path='./fonts/simhei.ttf',# 最大尺寸max_font_size=60,repeat=True)global word_cloud# 詞云函數(shù)x = wc.generate(word_cloud)# 生成詞云圖片image = x.to_image()# 展示詞云圖片image.show()# 保存詞云圖片wc.to_file('cloud.png')jieba_() cloud()效果如下:
素材及來(lái)源:https://www.cnblogs.com/ityard/p/13435685.html
總結(jié)
以上是生活随笔為你收集整理的最炫国漫《雾山五行》用 Python 了解一下到底有多优秀的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Django第一天笔记
- 下一篇: websocket python爬虫_p