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 make Python crawl the video barrage of bilibili's mouse tail juice without saying the provenance of martial arts?

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article shows you how to let Python crawl bilibili's mouse tail juice, without saying the origin of the video barrage, the content is concise and easy to understand, can definitely brighten your eyes, through the detailed introduction of this article, I hope you can get something.

Preface

What does the rat feed juice mean? what stem? Many people may not know that this stem comes from Ma Baoguo. People who often surf the Internet may have heard of this name, and some of what he said has also been regarded as a hindrance, such as young people who do not speak martial arts, Lightning five whips and so on.

In a video of bilibili Ma Baoguo, there are frequent red and swollen golden sentences in his right eye, and some of the classic sentences have even been summed up by netizens as "protecting the country", which has become a mantra, such as "Young people do not pay attention to martial arts." bully my 69-year-old comrade "rat tail juice" and so on.

So let's see what kind of barrage most netizens have sent.

Project goal

Climb bilibili's on-screen comment, ci cloud picture

The number of the first video broadcast is almost 2000W, and the on-screen comment also has 4.8W.

Once a day, the source of happiness, hey

Environment

Python3.6

Pycharm

Crawler code

Import tool

Import requestsimport parselimport csvimport time

Press F12 first to find out where the data on the barrage is.

Get the URL address and other data of the details page from the list page

For page in range (202.32): time.sleep (1) print ('= downloading November {} on-screen comment = '.format (page)) url =' https://api.bilibili.com/x/v2/dm/history?type=1&oid=140610898&date=2020-11-{}'.format(page) headers = {'user-agent':' Mozilla/5.0 (Windows NT 10.0; Win64) X64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36', "cookie": "_ _ uuid=1896D3F7-4A98-54EBMohamF7FAQUR 3301CE9EF5F307776Infofom; buvid3=B68B2187-4C3EKu4466FF9B292099B190963infocus.LIVE_BUVID=AUTO4115757254257055; stardustvideo=1; rpdid= | (umu | ulY) JJ0J'ul~l~klRJ); sid=8cq4r229; im_notify_type_65901796=0; laboratory=1-1; DedeUserID=523606542; DedeUserID__ckMd5=909861ec223d26d8; blackside_state=1; CURRENT_FNVAL=80; SESSDATA=a976c0b4%2C1618637313%2C4d792*a1; bili_jct=7f54729ec20660f750661122b80746d2; PVID=1; bp_video_offset_523606542=458111639975213216; CURRENT_QUALITY=16 Bfe_id=1e33d9ad1cb29251013800c68af42315 "} 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)

The word cloud code import jiebaimport wordcloudimport imageio# reads the file content f = open ('csv file address', encoding='utf-8') txt = f.read () # print (txt) # jiabe participle word txt_list = jieba.lcut (txt) string = '.join (txt_list) # the cloud image setting wc = wordcloud.WordCloud (width=800, # wide height=500 of the picture # High background_color='white', of the picture # picture background color font_path='msyh.ttc', # word cloud font # mask=py, # word cloud picture scale=15 ) # input text to the word cloud wc.generate (string) # word cloud map save picture address wc.to_file ('\ 1.png') the above content is how to make Python crawl the tail juice of bilibili's mouse without saying the source of martial arts. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

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: 0

*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