Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Python to climb bilibili's 18000 black myths Wukong real machine demonstration on-screen comment

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use Python to climb bilibili 18000 black mythology Wukong real machine demonstration barrage, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.

Development environment:

Python 3.6

Pycharm

Crawler part code

Import tool

Import requestsimport parselimport csvimport time

Request a web page and climb the on-screen comment

Url = 'https://api.bilibili.com/x/v2/dm/history?type=1&oid=226204073&date=2020-08-{}'.format(page) headers = {' user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36', "cookie": "_ uuid=50D22ECF-208D-9409-DEA1-0B3EA3F74AB793744infocu; buvid3=A0FE83C2-5981-40DCMuay C74E2A37227ECF155818 Infofoc; CURRENT_FNVAL=16 Rpdid= | (umuummlkY~0J'ulm | ullmll; sid=kr4i59d5; DedeUserID=65901796; DedeUserID__ckMd5=90847fa74c846032; SESSDATA=896f66c1%2C1606454910%2Ceacc7*51; bili_jct=2768c9f3a50e5333de1422cd66782350; LIVE_BUVID=AUTO3215909029132687; blackside_state=1; bsource=search_baidu; bp_video_offset_65901796=429260996026495399; bp_t_offset_65901796=429524591059675137; _ dfcaptcha=0543580ac4738e5ca1bdae06da0ee65b PVID=6 "} response = requests.get (url=url, headers=headers) response.encoding = response.apparent_encoding selector = parsel.Selector (response.text) data = selector.css. Getall () for i in data: print (I) with open ('bilibili on-screen comment .c sv', mode='a', newline='') Encoding='utf-8-sig') as f: writer = csv.writer (f) links = [] links.append (I) writer.writerow (links)

Run the code, and the result is as follows

Word cloud map code

Enter the word cloud production library wordcloud and the Chinese word segmentation library jieba

Import jiebaimport wordcloud

Import the imread function in the imageio library, and use this function to read local pictures as word cloud shape pictures

Import imageiopy = imageio.imread (r "fist .png") w = wordcloud.WordCloud (width=1000, height=700, background_color='white', font_path='msyh.ttc', mask=py, scale=15, stopwords= {''} ) # students who want the complete source code can follow my official account: squirrels love cookies # reply to "Wukong" and get it for free

Export word cloud pictures to the current folder

W.to_file ('Wukong .png')

Final effect picture

Original drawing

Thank you for reading this article carefully. I hope the article "how to use Python to climb bilibili's 18000 real machine demonstration of Black Myth Wukong" will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 278

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report