Python auto-launch bomb screen, bullet screen protection body
-Environment: Python3+windows
-Development tools: Pycharm
Learning effect:
1. Learn how to use Python to brush the bullet screen
2. Configuring INI file Information
3. Mastering Network Request Knowledge
4. Solution Browser Developer Tools
5. Use of the time module
6. Basic knowledge of reptiles
https://www.bilibili.com/video/av11149694/
Manually send two bullets, grab the packet to view the form data, find out the different parameters, notice the corresponding modification
User login information, message header-cookie
The script is as follows:
#coding =utf-8import requests,time,randomimport Configparser #配置文件信息target = Configparser. Configparser () #文件对象target. Read (R ' D:\t.ini ', encoding= ' utf-8 ') #读取文件
While True: #message = target[' My barrage '][str (Random.randint (1,8))] message = Target.get (' My pinball ', str (random.randint (1,8)) url = ' https://interface.bilibili.com/dmpost?cid=18447007&aid=11149694&pid=1&ct=1 ' cookie = {' Cookie ': '} form = {' fontsize ': ' + ', ' pool ': ' 0 ', ' mode ': ' 1 ', ' Color ': ' 16777215 ', ' rnd ': Str (time.tim E () *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.R Equest (' POST ', URL, data=form,cookies=cookie) print (Message) Time.sleep (5)
The configuration file is as follows:
Python Auto Launch bullet screen