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 automatically send on-screen comments to your favorite anchors

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly shows you "how to use Python to automatically send on-screen comments to your favorite anchors". The content is easy to understand and well-organized. I hope it can help you solve your doubts. Let the editor lead you to study and learn the article "how to use Python to automatically send on-screen comments to your favorite anchors".

Preface

On-screen comment is only one of the small functions, and it can also automatically like, collect, coin, auto-play, private messages and so on, but we only demonstrate this, but we don't show the rest.

Implementation steps

First open a video or live broadcast, F12 open the developer tool and click network.

Then click this to empty it.

Send another on-screen comment, and then you can see the send with a post request.

Click payload to see the data related to the on-screen comment we just sent.

And then write the code.

First import the module

Import randomimport time

This is our url.

Url = 'https://api.live.bi******.com/msg/send'# for some reasons I won't play all of them.

Receive the data parameter

Data = {'bubble':' 0, 'msg': 6666,' color': '16777215,' mode':'1, 'fontsize':' 25, 'rnd':' 1640181316, 'roomid':' 22819508, 'csrf':' 131d24bf2b92a3609208ed83758ab8f2, 'csrf_token':' 131d24bf2b92a3609208ed83758ab8f2,}

Then headers request header here, add cookie and so on to it.

Headers = {'cookie':' _ uuid=CF79473B-0F83-6087-BCB0-23A7E36C479296281infocu; buvid3=8AEBDC64-0CEEfu4F6FLF9866Liv B1508FAB2871148805infocus; blackside_state=1; rpdid= | (kmJY | kmu |) 0J\ 'uYJRYkJu | Y; CURRENT_QUALITY=32; buvid_fp=8AEBDC64-0CEEmae 4F6Fafe 9866flim B1508FAB2871148805infocus1; video_page_version=v_old_home; sid=abkn3and; iMWannaMutual backtalk CURRENT_QUALITY=32; buvid_fp=8AEBDC64 1; baud utterances 5; bp_video_offset_65901796=602085772740229500; LIVE_BUVID=AUTO5916400017585242; CURRENT_BLACKGAP=1; CURRENT_FNVAL=2000; bauhinlsidents FB21108D717DE26BCC89; fingerprint=3c7949ca118951ae1be0b5b37b321306; buvid_fp_plain=556F173C-C5B7-4583-86F9FD104EB421D1476infoci; DedeUserID=523606542 DedeUserID__ckMd5=909861ec223d26d8; SESSDATA=cec4dda4%2C1655733287%2Cc5b88*c1; bili_jct=131d24bf2b92a3609208ed83758ab8f2; innersign=0; _ dfcaptcha=fbb016616944e9b94331aeb2627c9d3d; PVID=3', 'origin':' https://live.bi****.com', 'referer':' https://live.bi****.com/', 'user-agent':' Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36',}

Receive data

Response = requests.post (url=url, data=data, headers=headers)

Output

Print (response.text)

This is the simplest version, just four lines of code.

Found a video that no one watched and ran it, and sent a hello.

What if you want to send a little more?

Give it a list.

Lis = ['Anchor 666',' Anchor really handsome', '666']

The imported random module is designed to pick a random on-screen comment.

Word = random.choice (lis)

And then we're writing an endless loop.

While True: lis = ['VJ 666','VJ is really handsome', '666'] word = random.choice (lis)

The imported time is a delay function. After we send it each time, we delay it for five seconds and put it at the end.

Time.sleep (5)

Let's see the effect again.

All codes import randomimport timewhile True: lis = ['VJ 66615,'VJ really handsome', '666'] word = random.choice (lis) url =' https://api.live.bi****.com/msg/send' data = {'bubble':' 015, 'msg': word,' color': '16777215,' mode':'1' 'fontsize':' 25, 'rnd':' 1640181316, 'roomid':' 22819508, 'csrf':' 131d24bf2b92a3609208ed83758ab8f2, 'csrf_token':' 131d24bf2b92a3609208ed83758ab8f2,} headers = {'cookie':' _ uuid=CF79473B-0F83-6087-BCB0-23A7E36C479296281infoc Buvid3=8AEBDC64-0CEElu4F6Fly9866After B1508FAB2871148805infocu; blackside_state=1; rpdid= | (kmJY | kmu |) 0J\ 'uYJRYkJu | Y; CURRENT_QUALITY=32; buvid_fp=8AEBDC64-0CEEMush4FFFLF9866Linfo B1508FAB2871148805infocus1; baked utters 5; bp_video_offset_65901796=602085772740229500; LIVE_BUVID=AUTO5916400017585242; CURRENT_BLACKGAP=1; CURRENT_FNVAL=2000; baked lsiders FB21108D717DE26BCC89; fingerprint=3c7949ca118951ae1be0b5b37b321306; buvid_fp_plain=556F173C-C5B7-4583-86F9 FD104EB421D143076infoc; DedeUserID=523606542; DedeUserID__ckMd5=909861ec223d26d8; SESSDATA=cec4dda4%2C1655733287%2Cc5b88*c1; bili_jct=131d24bf2b92a3609208ed83758ab8f2; innersign=0; _ dfcaptcha=fbb016616944e9b94331aeb2627c9d3d PVID=3', 'origin':' https://live.bi****.com', 'referer':' https://live.bi****.com/', 'user-agent':' Mozilla/5.0 (Windows NT 10.0; Win64 X64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36',} response = requests.post (url=url, data=data, headers=headers) print (response.text) time.sleep (5) above are all the contents of the article "how to use Python to automatically send on-screen comments to your favorite VJs". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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

Development

Wechat

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

12
Report