声明
仅供学习,禁止用于违法行为。请勿利用文章内的相关技术从事非法测试,如因此产生的一切不良后果与文章作者和本公众号无关。
功能
- 登录签到
- 视频观看
- 5次投币(需消耗5个币,没有则会投币失败)
- 分享视频(不会发在个人空间动态里)
以上每天经验共65点经验
脚本
import requestsimport jsonimport timeimport randomdef extract_cookies(cookies): global csrf cookies = dict([l.split("=", 1) for l in cookies.split("; ")]) csrf = cookies['bili_jct'] return cookiesdef getCoin(): cookie = extract_cookies(cookies) url = "http://account.bilibili.com/site/getCoin" r = requests.get(url, cookies=cookie).text j = json.loads(r) money = j['data']['money'] return moneydef getInfo(): global uid url = "http://api.bilibili.com/x/space/myinfo" cookie = extract_cookies(cookies) r = requests.get(url, cookies=cookie).text j = json.loads(r) uid = j['data']['mid'] name = j['data']['name'] level = j['data']['level'] current_exp = j['data']['level_exp']['current_exp'] next_exp = j['data']['level_exp']['next_exp'] sub_exp = int(next_exp)-int(current_exp) days = int(int(sub_exp)/65) coin = getCoin() msg = "你目前的等级是"+str(level)+"级" + " ,目前的经验:" + \ str(current_exp)+",离下个等级还差"+str(sub_exp)+"经验" + \ " ,需要"+str(days)+"天,"+"剩余硬币还有 "+str(coin)+"个。" print(msg)def getActiveInfo(): url = "http://api.bilibili.com/x/web-interface/archive/related?aid=" + \ str(7) cookie = extract_cookies(cookies) r = requests.get(url, cookies=cookie).text j = json.loads(r) return jdef Task(): j = getActiveInfo() data = j['data'] coin_count = 0 for i in range(0, len(data)): bvid = data[i]['bvid'] aid = data[i]['aid'] print(str(bvid)+' ---- '+str(aid)) if coin_count < 5: coin_code = tocoin(bvid) if coin_code == -99: return time.sleep(3) toview(bvid) time.sleep(3) shareVideo(bvid) if coin_code == 1: coin_count = coin_count+1 if coin_count == 5: break print('----------------------')def toview(bvid): playedTime = random.randint(10, 100) url = "https://api.bilibili.com/x/click-interface/web/heartbeat" data = { 'bvid': bvid, 'played_time': playedTime, 'csrf': csrf } cookie = extract_cookies(cookies) r = requests.post(url, data=data, cookies=cookie).text j = json.loads(r) code = j['code'] if code == 0: print('观看视频成功!') else: print('观看视频失败!')def shareVideo(bvid): url = "https://api.bilibili.com/x/web-interface/share/add" data = { 'bvid': bvid, 'csrf': csrf } cookie = extract_cookies(cookies) header = { "Content-Type": "application/x-www-form-urlencoded", "Connection": "keep-alive", "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36 Edg/93.0.961.38", } r = requests.post(url, data=data, cookies=cookie, headers=header).text j = json.loads(r) code = j['code'] if code == 0: print('分享成功!') else: print('分享失败!')def tocoin(bvid): coinNum = getCoin() if coinNum == 0: print('硬币不够 !') return -99 url = "http://api.bilibili.com/x/web-interface/coin/add" data = { 'bvid': bvid, 'multiply': 1, 'select_like': 1, 'csrf': csrf } cookie = extract_cookies(cookies) r = requests.post(url, data=data, cookies=cookie).text j = json.loads(r) code = j['code'] print("code="+str(code)) if code == 0: print(str(bvid)+' 投币成功 !') return 1 else: print(str(bvid)+' 投币失败!') return 0def run(): getInfo() Task()if __name__ == '__main__': cookies =input('请输入cookie:') run() print('今日签到完成。')
用法
- 浏览器进入哔哩网站(https://www.bilibili.com),登录自己的账号
- 访问 http://api.bilibili.com/x/space/myinfo
- F12看到cookie的值粘贴即可
效果
结尾
每天跑一跑,收集经验进行升级,嘿嘿。以后会持续输出文章,师傅们轻喷。