
破站今天又改版了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);
}
}
手机写的不咋地,大佬勿喷~~
需要有本地读写权利,不然无限领来领去就不好玩了。
好了好了,水完一波就可以撤了
I want to to thank you for this good read!! I absolutely loved every bit of it.
I have you bookmarked to check out new things you post…
2018年8月8日 22:18This web site definitely has all of the info I wanted about this subject and didn’t know who to ask.
2018年8月8日 20:36Awesome! Its genuinely awesome paragraph, I have got much clear idea on the topic of from
2018年8月8日 20:02this piece of writing.
I like what you guys are up too. This sort of clever work and
2018年8月8日 19:53coverage! Keep up the excellent works guys I’ve added you guys to my blogroll.
Your means of explaining everything in this paragraph is genuinely nice, all be able to simply know it, Thanks a lot.
2018年8月8日 19:39Good day I am so delighted I found your blog, I really found you
2018年8月8日 19:38by mistake, while I was looking on Google for something else,
Nonetheless I am here now and would just like to say thanks for a marvelous post and
a all round interesting blog (I also love the theme/design), I don’t have time to browse it all at
the minute but I have book-marked it and also
added in your RSS feeds, so when I have time I will be back to read a great
deal more, Please do keep up the fantastic job.
It’s really a nice and useful piece of information. I’m happy that
2018年8月8日 19:37you shared this helpful info with us. Please keep us informed like this.
Thanks for sharing.
I am really impressed together with your writing skills and also with
2018年8月8日 18:11the structure on your weblog. Is that this a paid subject
matter or did you modify it yourself? Anyway keep up the
excellent quality writing, it’s rare to look a nice blog like this one these days..
I do not know whether it’s just me or if perhaps everyone else encountering problems with
2018年8月8日 17:48your blog. It looks like some of the text within your posts are running off the screen. Can somebody else please comment and let
me know if this is happening to them too? This could be a problem with my web browser because I’ve had this happen before.
Thank you
I will immediately clutch your rss as I can not find your e-mail subscription link or newsletter service.
2018年8月8日 16:19Do you’ve any? Kindly allow me recognise so that
I could subscribe. Thanks.