In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to realize the automatic sending function of live on-screen comment by Python". The explanation in this article is simple, clear and easy to learn and understand. Please follow the editor's train of thought to study and learn "how to achieve automatic sending of live on-screen comment by Python".
Preface
Open a live room first.
Press F12 to open developer tools
Send on-screen comment 666
Find the link we need in send
Send a request
Need to add headers and data
Import requestsurl = 'https://api.live.bilibili.com/msg/send'data = {' bubble':'0, 'msg':' 666666, 'color':' 16777215, 'mode':' 1, 'fontsize':' 25, 'rnd':' 1646460756, 'roomid':' 545068, 'csrf':' a121a39614a5131b700e07334c3e2f2e, 'csrf_token': 'a121a39614a5131b700e07334c3e2f2e` } headers = {'cookie':' buvid3 = B68B2187-4C3E-4466-A896-FBF9B292099B190963infoc LIVE_BUVID = AUTO4115757254257055;rpdid = | (umu | ulY) JJ0J\ 'ul~l~klRJ); Hm_lvt_ff57561a8cad2056ebeb8790418f7c80=1617598823; dy_spec_agreed=1; fingerprint_s=72d878d168cc36c3e67084f9ab1b28bf; kfcFrom=SIXIN; video_page_version=v_old_home; _ uuid=838215105-B7C3-D1D3-8866 fingerprint3=282838a0bbd808eda8dde1558fccc94c; CURRENT_QUALITY=80; bp_video_offset_296816901=629971213059358700; sid=jtva59n5; fingerprint=416f0a37448a1faf863af4402998db67; DedeUserID=523606542; DedeUserID__ckMd5=909861ec223d26d8 D41AAC22362C56007 Infoci; CURRENT_BLACKGAP=0; blackside_state=0; buvid_fp_plain=undefined; buvid4=475D6CE2-93EF-3AD0-EBCD-C528FD289A2218219-022015kzgH6uKZsx6eQ% 3D% 3D; iMuvwannaMuturowannaMustr SESSDATA=c666f798%2C1661245310%2C91227*21; bili_jct=ac2dd02c170854b995d5a6a601d973ea; buvid_fp=416f0a37448a1faf863af4402998db67; bounded utterances 5; bp_t_offset_523606542=630736739432923172; bp_video_offset_523606542=631076973870841894; innersign=0; bounded lsiders B77BFA43 17F2FE6E01B; CURRENT_FNVAL=80; _ dfcaptcha=fa1b3951be7c6744827b636f6c4935c9; Hm_lvt_8a6e55dbd2870f0f5bc9194cddf32a02=1645778002; Hm_lpvt_8a6e55dbd2870f0f5bc9194cddf32a02=1645778002 PVID=7', 'origin':' https://live.bilibili.com', 'referer':' https://live.bilibili.com/blanc/1029?liteVersion=true', 'user-agent':' Mozilla/5.0 (Windows NT 10.0 WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36',response = requests.post (url=url, data=data, headers=headers) print (response.status_code) circulate on-screen comment import randomimport timelis_text = ['666','VJ is really good', 'Love, Love', 'focus on walking, live to 99'! , 'Xiuer, is that you?'] While True: time.sleep (2) send_meg = random.choice (lis_text) roomid = entry.get () ti = int (time.time ()) url = 'https://api.live.bilibili.com/msg/send' data = {' color': '16777215,' fontsize':'25, 'mode':' 1, 'msg': send_meg 'rnd':' {} '.format (ti),' roomid':'{} '.format (roomid),' bubble': '0mm,' csrf': 'ac2dd02c170854b995d5a6a601d973ea',' csrf_token': 'ac2dd02c170854b995d5a6a601d973ea',}
Make an interactive interface.
From tkinter import * root = Tk () root.title ('bilibili automatically sends on-screen comment') root.geometry ('560x450 / 400 / 200') label = Label (root, text=', please enter the room number:', font= ('Chinese script', 20) label.grid () entry = Entry (root, font= ('official script', 20)) entry.grid (row=0, column=1) text= Listbox (root, font= ('official script', 16), width=50, heigh=15) text.grid (row=2, columnspan=2) root.mainloop ()
Set the code that sent the on-screen comment to a function, and then call the
Button1 = Button (root, text=' start sending', font= ('official script', 15), command=send) button1.grid (row=3, column=0) button2 = Button (root, text=' exit program', font= ('official script', 15), command=root.quit) button2.grid (row=3, column=1) finally see how it works
Thank you for your reading. The above is the content of "how to realize the automatic transmission of live on-screen comment by Python". After the study of this article, I believe you have a deeper understanding of how to realize the automatic transmission of live on-screen comment by Python, and the specific usage needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.