Bilibili自动点赞投币机

某人的视频太多了啊 投币投不过来了
索性写了个自动投币

# -*- coding=utf-8 -*-
import requests,json,re,time
def coinadd(av):

    headers = {
        "Host": "api.bilibili.com",
        "Cache-Control": "no-cache",
        "Proxy-Connection": "keep-alive",
        "Accept": "application/json, text/javascript, */*; q=0.01",
        "Origin": "https://www.bilibili.com",
        "Referer": "https://www.bilibili.com/video/av" + str(av),
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36",
        "Accept-Encoding": "gzip, deflate",
        "Accept-Language": "zh-CN,zh;q=0.9"
    }
    cookies = {#这里放入你的cookie 不会抓自己百度
        'DedeUserID': '',
        'bili_jct': '',
        'SESSDATA': ''
    }
    prompt_data = {'aid': str(av), 'multiply': '2', 'select_like': '1', 'cross_domain': 'true','csrf': cookies['bili_jct']}
    test_page = requests.post("https://api.bilibili.com/x/web-interface/coin/add",data = prompt_data,headers=headers,cookies = cookies)
    #print(test_page.text)
uid=input("up主的uid")
#下面这里去up主主页https://space.bilibili.com/加上up主的uid/video?tid=0&page=1&keyword=&order=pubdate   看一下总共有几页 下面的9就换成n+1页
for i in range(1,9):
    vpage = requests.get('https://api.bilibili.com/x/space/arc/search?mid='+uid+'&pn='+str(i)).text
    #print(vpage)
    avlisttmp = re.compile(r"\"aid\":(\w+)").findall(vpage)
    for av in avlisttmp:
        coinadd(av)
        time.sleep(100)
        

码力有限 请谅解
加个自动评论 不过十个以上就要验证码了

# -*- coding=utf-8 -*-
def replyadd(av,cnt):
    headers = {
        "Host": "api.bilibili.com",
        "Cache-Control": "no-cache",
        "Proxy-Connection": "keep-alive",
        "Accept": "application/json, text/javascript, */*; q=0.01",
        "Origin": "https://www.bilibili.com",
        "Referer": "https://www.bilibili.com/video/av" + str(av),
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36",
        "Accept-Encoding": "gzip, deflate",
        "Accept-Language": "zh-CN,zh;q=0.9"
    }
    cookies = {
        'DedeUserID': '',
        'bili_jct': '',
        'SESSDATA': ''
    }
    prompt_data = {'oid': str(av), 'type': '1', 'message': '你想输入的评论'+str(cnt), 'plat': '1','ordering':'heat','jsonp':'jsonp','csrf': cookies['bili_jct']}
    test_page = requests.post("https://api.bilibili.com/x/v2/reply/add", data=prompt_data, headers=headers,
                              cookies=cookies)
    print(test_page.text)
cnt=0
for i in range(1,9):
    vpage = requests.get('https://api.bilibili.com/x/space/arc/search?mid=同上&pn='+str(i)).text
    print(vpage)
    avlisttmp = re.compile(r"\"aid\":(\w+)").findall(vpage)
    for av in avlisttmp:
        cnt=cnt+1
        replyadd(av,cnt)

你可能感兴趣的:(奇思妙想,python)