
破站今天又改版了pc端的api真的难受,拿手机重新抓了一遍包,修了修然后正好无聊突然想起来之前在群里说弄个简易的抢电视脚本自己抢
想了想似乎懒癌发作想弄什么什么都没弄,既然正好吃完饭有点时间就拿手机蛋疼的写了这么个脚本
因为礼物信息需要socket监控弹幕,普通fpm运行下的php是肯定搞不定的,这个脚本是直接抓取我直播间的弹幕查看是否有礼物需要领取
输入自己的cookie直接监控php脚本就可以了,想多快就自己决定了,不过一定不要太...长了
直接丢代码
<?php
/*
Name:简易B站领小电视脚本
Design:小幻酱吖
*/
$cookie = '输入你的帐号cookie';
function curl($url, $cookie = null, $refer = null) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $refer);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 BIDUBrowser/8.3 Safari/537.36");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 6);
$re = curl_exec($ch);
curl_close($ch);
return $re;
}
$msglist = json_decode(curl('http://api.live.bilibili.com/AppRoom/msg?room_id=2026835'),true);
$msg = $msglist['data']['room'][9]['text'];
$time = $msglist['data']['room'][9]['timeline'];
$id = md5($msg.$time);
$log = file_get_content('log.db');
if(strpos($log,$id)){
exit('没有需要抢的');
}
$id);
if(strpos($msg,'小电视')){
file_put_content('log.db',$log.PHP_EOL.
$roomid = str_replace('小电视X1','',$msg);
$raffleId = json_decode(curl('http://api.live.bilibili.com/gift/v2/smalltv/check?roomid='.$roomid),true);//5.6以下PHP版本问题麻烦一点咯
foreach($raffleId['data'] as $data){
$raffle = $data['raffleId'];
echo curl('http://api.live.bilibili.com/gift/v2/smalltv/join?roomid='.$roomid.'&raffleId='.$raffle,$cookie,'http://live.bilibili.com/'.$roomid);
}
}
手机写的不咋地,大佬勿喷~~
需要有本地读写权利,不然无限领来领去就不好玩了。
好了好了,水完一波就可以撤了
Thank you for the good writeup. It in fact was a amusement account it.
2018年7月9日 11:01Look advanced to far added agreeable from you! By the way, how could we communicate?
Appreciation to my father who shared with me about this blog, this website is
2018年7月9日 09:38truly awesome.
Hello! I know this is kind of off topic but I was wondering which blog platform are
2018年7月9日 08:38you using for this site? I’m getting tired of WordPress because I’ve had problems with hackers and I’m looking at
options for another platform. I would be awesome if you could point me in the direction of a good platform.
My coder is trying to convince me to move to .net
from PHP. I have always disliked the idea because of the costs.
But he’s tryiong none the less. I’ve been using
Movable-type on several websites for about a year and am worried about switching to another platform.
I have heard very good things about blogengine.net.
Is there a way I can import all my wordpress content into it?
2018年7月9日 08:27Any kind of help would be greatly appreciated!
That is a very good tip especially to those new to the blogosphere.
2018年7月9日 06:47Short but very precise information… Thanks for sharing this one.
A must read post!
Hey this is somewhat of off topic but I was wondering if blogs use WYSIWYG editors or if you
2018年7月9日 06:00have to manually code with HTML. I’m starting a blog soon but have no
coding expertise so I wanted to get guidance from someone
with experience. Any help would be greatly appreciated!
I visited multiple sites but the audio quality for audio songs present at this web
2018年7月9日 03:54site is actually marvelous.
Do you have a spam issue on this site; I also am a blogger, and
2018年7月9日 01:14I was wanting to know your situation; we have developed some nice practices and
we are looking to exchange methods with other folks,
please shoot me an email if interested.
Great site you’ve got here.. It’s difficult to find high-quality writing like yours these days.
2018年7月9日 00:39I truly appreciate individuals like you! Take care!!
That is very attention-grabbing, You are a very skilled blogger.
I have joined your feed and stay up for in the hunt for more of your excellent post.
2018年7月8日 22:35Also, I’ve shared your site in my social networks