Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use Python to crawl 1.4w video data of teacher Ma on bilibili to analyze

Shulou Source: shulou.com Published: 2022-06-02 01:15:00 10月02日 Update

This article introduces how to use Python to climb 1.4w Ma teacher video data on bilibili to analyze, the content is very detailed, interested friends can refer to, hope to be helpful to you.

See the title

You came in with a bang!

If there are friends who often brush bilibili, they must know who the top stream of bilibili ghosts and livestock is now.

India: yes, it is.

That must be the contemporary master Hunyuan Xingyi Taijiquan master "Ma Baoguo"!

To be honest, Ma Baoguo entered the public eye or he competed in May when he was KO three times in a row.

But now his main material in the ghost area is some of Ma Baoguo's earlier videos.

For example, in January 2020, Mr. Ma, who was rubbed on his right eye, smiled and vividly told us the story of how the young man in the gym attacked him without speaking martial arts.

In the video, he accused the young people who kicked the gym of "not paying attention to martial arts" and advised him to have "rat tail juice". Can be used as bilibili entry topic, it is recommended to recite the full text.

Bilibili, a clever little ghost, even opened a special column for teacher Ma, which brought convenience for us to crawl data later.

Unlike usual climbing bilibili, under bilibili's Ma Baoguo column, F12 can easily find the interface.

Https://api.bilibili.com/x/web-interface/web/channel/multiple/list?channel_id=3503796&sort_type=hot&page_size=30

After parsing JSON, all the data we need can be obtained.

It is important to mention that the offest in url is obtained from the json parsing the previous url, as shown in the following figure.

Through a short crawler code

Very soon, 14000 pieces of Mr. Ma Baoguo's video data were crawled.

Def get_data (url,headers):

Data_m = pd.DataFrame (columns= ['id','name','view_count','like_count','duration','author_name','author_id','bvid'])

Html = requests.get (url,headers=headers) .content

Data = json.loads (html.decode ('utf-8'))

Offset = data ['data'] [' offset']

Print (offset)

For j in range (30):

Data_m = data_m.append ({'id':data [' data'] ['list'] [j] [' id'], 'name':data [' data'] ['list'] [j] [' name'])

'view_count':data [' data'] ['list'] [j] [' view_count'], 'like_count':data [' data'] ['list'] [j] [' like_count']

'duration':data [' data'] ['list'] [j] [' duration'], 'author_name':data [' data'] ['list'] [j] [' author_name']

'author_id':data [' data'] ['list'] [j] [' author_id'], 'bvid':data [' data'] ['list'] [j] [' bvid']}, ignore_index=True)

Return (offset,data_m)

14000 pieces of data preview

After a simple collation of data (some tens of thousands of videos are played), we make a scatter chart of 14000 videos according to the number of views and likes.

You can see what is the topic of "top stream". There are many related videos with millions of views and hundreds of thousands of likes.

Sort it by the number of broadcasts.

The first place is crosstalk in January this year, classic stand-up crosstalk!

What about according to the amount of praise?

The first place is from the ghost animal up master Elizabeth mouse "Wulin master"!

And understand Wang and Ma teacher's linkage performance is also very excellent!

The performance of several special effects is even more outstanding!

As Mr. Ma's quotation is too classic, I decided to add and climb its on-screen comment.

# draw word cloud map

Stylecloud.gen_stylecloud (text=''. Join (text1))

Collocations=False

Font_path=r' ‪ C:\ Windows\ Fonts\ msyh.ttc'

Icon_name='fas fa-play-circle'

Size=653

Output_name=' Ma Baoguo ci cloud picture. PNG')

Image (filename=' Ma Baoguo word cloud picture. PNG')

Rat tail juice is really a facade!

Tingting, English marble and Tamen are also among them.

On how to use Python to climb 1.4w of bilibili teacher video data to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Data teacher video national protection cloud map analysis young ten thousand articles column sir content boys buddies young people soon more crosstalk classics mice martial arts Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Xiaomi NVidia Linux Apple