Python自動發射彈幕


Python自動發射彈幕,彈幕護體

- 環境: Python3+Windows
- 開發工具: PyCharm 

學習效果:
1. 學會使用Python刷彈幕
2. 配置INI文件信息
3. 掌握網絡請求知識
4. 解瀏覽器開發者工具
5. 時間模塊的使用
6.爬蟲的基本知識

 

https://www.bilibili.com/video/av11149694/

手動發送兩條彈幕,抓包查看表單數據,找出不同的參數,注意相應修改

用戶登錄信息,消息頭-cookie

 

 腳本如下:

#coding=utf-8
import requests,time,random
import configparser  #配置文件信息

target = configparser.ConfigParser() #文件對象
target.read(r'D:\t.ini',encoding='utf-8')  #讀取文件
while True: #message = target['我的彈幕'][str(random.randint(1,8))] message = target.get('我的彈幕',str(random.randint(1,8))) url = 'https://interface.bilibili.com/dmpost?cid=18447007&aid=11149694&pid=1&ct=1' cookie = {'cookie':''} form = {'fontsize':'25', 'pool':'0', 'mode':'1', 'color':'16777215', 'rnd':str(time.time()*1000000),#時間戳 'message':message, 'playTime':'0.08', 'cid':'18447007', 'date':time.strftime('%Y-%m-%d+%H:%M:%S',time.localtime(time.time())), #'date':time.strftime('%Y-%m-%d+%X', time.localtime(time.time())), 'csrf':'3915a57109e4abe13dc752254df4bc35' } requests.post(url,cookies=cookie,data=form) # requests.request('POST',url, data=form,cookies=cookie) print(message) time.sleep(5)

 

配置文件如下: 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM