怎么用python发弹幕_Python自动发射弹幕

Python自动发射弹幕,弹幕护体

- 环境: Python3+Windows

- 开发工具: PyCharm

学习效果:

1. 学会使用Python刷弹幕

2. 配置INI文件信息

3. 掌握网络请求知识

4. 解浏览器开发者工具

5. 时间模块的使用

6.爬虫的基本知识

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

手动发送两条弹幕,抓包查看表单数据,找出不同的参数,注意相应修改

用户登录信息,消息头-cookie

1236609-20171224112033381-1852110736.png

脚本如下:

#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)

配置文件如下:

1236609-20171224113142053-2125834061.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Danmaku2ASS 用来将来自 Niconico/Acfun/Bilibili 的评论转成 ASS 格式,这样就可以在任意支持 ASS 字母的媒体播放器中使用弹幕。使用方法:usage: danmaku2ass.py [-h] [-f FORMAT] [-o OUTPUT] -s WIDTHxHEIGHT [-fn FONT]                       [-fs SIZE] [-a ALPHA] [-dm SECONDS] [-ds SECONDS]                       [-fl FILTER] [-p HEIGHT] [-r]                       FILE [FILE ...] positional arguments:   FILE                  Comment file to be processed optional arguments:   -h, --help            show this help message and exit   -f FORMAT, --format FORMAT                         Format of input file (autodetect|Bilibili|Tudou2|MioMi                         o|Acfun|Niconico|Tudou) [default: autodetect]   -o OUTPUT, --output OUTPUT                         Output file   -s WIDTHxHEIGHT, --size WIDTHxHEIGHT                         Stage size in pixels   -fn FONT, --font FONT                         Specify font face [default: sans-serif]   -fs SIZE, --fontsize SIZE                         Default font size [default: 25]   -a ALPHA, --alpha ALPHA                         Text opacity   -dm SECONDS, --duration-marquee SECONDS                         Duration of scrolling comment display [default: 5]   -ds SECONDS, --duration-still SECONDS                         Duration of still comment display [default: 5]   -fl FILTER, --filter FILTER                         Regular expression to filter comments   -p HEIGHT, --protect HEIGHT                         Reserve blank on the bottom of the stage   -r, --reduce          Reduce the amount of comments if stage is full 标签:Danmaku2ASS
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值