登录签到
视频观看
5次投币(需消耗5个币)
分享视频(不会发在个人空间动态里)
以上每天经验共65点经验。
1、浏览器登入哔哩网站
2、访问
http://api.bilibili.com/x/space/myinfo
3、F12看到cookie的值粘贴即可
[mw_shl_code=python,true]# -*- coding: utf8 -*-
import requests
import json
import time
import random
# 填写cookie即可运行
”’
1、浏览器登入哔哩网站
2、访问
http://api.bilibili.com/x/space/myinfo
3、F12看到cookie的值粘贴即可
”’
cookies = “”
# cookie转字典
def extract_cookies(cookies):
global csrf
cookies = dict([l.split(“=”, 1) for l in cookies.split(“; “)])
csrf = cookies[‘bili_jct’]
return cookies
# 银币数
def 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 money
# 个人信息
def 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 = “Welcome! Current level is “+str(level) + ” ,Current experience are ” + \
str(current_exp)+”,Not far from upgrading “+str(sub_exp) + \
” ,need “+str(days)+” days”+”Remaining silver coins are “+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 j
# 投币 分享5次
def Task():
j = getActiveInfo()
data = j[‘data’]
coin_count = 0
for i in range(0, len(data)):
bvid = data
[‘bvid’]
aid = data[‘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(‘watching viedo successful!’)
else:
print(‘watching viedo failed!’)
# 分享视频
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(‘share successful!’)
else:
print(‘share failed!’)
# 投币函数
def tocoin(bvid):
coinNum = getCoin()
if coinNum == 0:
print(‘not enough coin !’)
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)+’ toaddcoin successful !’)
return 1
else:
print(str(bvid)+’ toaddcoin failed!’)
return 0
def run():
getInfo()
Task()
# 云函数时运行
def main_handler(event, context):
print(“Received event: ” + json.dumps(event, indent=2))
print(“Received context: ” + str(context))
run()
return(” —— end ——“)
if __name__ == ‘__main__’:
run()
[/mw_shl_code]
抓取ck教程
不会可以留言 是在不会 给我发邮件:admin@hicy.cn
云函数使用