├── .github └── workflows │ └── run_52pojie_sign.yml ├── 52pojieCheckIn.py ├── BilibiliCheckIn.py ├── README.MD └── bs4.zip /.github/workflows/run_52pojie_sign.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: 'run 52pojie sign' 4 | 5 | # Controls when the action will run. Triggers the workflow on push or pull request 6 | # events but only for the master branch 7 | on: 8 | schedule: 9 | - cron: '0 0 * * *' #早上8点执行 10 | workflow_dispatch: 11 | 12 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 13 | jobs: 14 | 15 | run: 16 | # The type of runner that the job will run on 17 | runs-on: ubuntu-latest 18 | 19 | # Steps represent a sequence of tasks that will be executed as part of the job 20 | steps: 21 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 22 | - uses: actions/checkout@v2 23 | 24 | - name: 安装python3 25 | run: sudo apt-get update && sudo apt-get install python3 python3-pip python3-bs4 && sudo pip install requests 26 | 27 | - name: 在脚本中填入用户参数 28 | run: | 29 | sed -i 's/你的server酱SCKEY/${{ secrets.SCKEY }}/' ./52pojieCheckIn.py 30 | sed -i 's/你的cookie/${{ secrets.cookie }}/' ./52pojieCheckIn.py 31 | - name: 执行签到程序 32 | run: python3 ./52pojieCheckIn.py 33 | -------------------------------------------------------------------------------- /52pojieCheckIn.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | import requests 3 | from bs4 import BeautifulSoup 4 | 5 | cookie = '' # 配置你的cookie 6 | sckey = '' # 配置你的server酱SCKEY 7 | 8 | def pushinfo(info,specific): 9 | headers={ 10 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36', 11 | 'ContentType': 'text/html' 12 | } 13 | requests.session().get("https://sc.ftqq.com/"+sckey+".send?text=" + info + "&desp=" + specific,headers=headers) 14 | 15 | def main(*args): 16 | headers={ 17 | 'Cookie': cookie, 18 | 'ContentType':'text/html;charset=gbk' 19 | } 20 | requests.session().get('https://www.52pojie.cn/home.php?mod=task&do=apply&id=2',headers=headers) 21 | a=requests.session().get('https://www.52pojie.cn/home.php?mod=task&do=draw&id=2',headers=headers) 22 | b=BeautifulSoup(a.text,'html.parser') 23 | c=b.find('div',id='messagetext').find('p').text 24 | 25 | if "您需要先登录才能继续本操作" in c: 26 | pushinfo("Cookie失效", c) 27 | elif "恭喜" in c: 28 | pushinfo("吾爱破解签到成功",c) 29 | else: 30 | pushinfo("吾爱破解签到失败",c) 31 | print(c) 32 | 33 | 34 | if __name__ == '__main__': 35 | main() -------------------------------------------------------------------------------- /BilibiliCheckIn.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | import requests 3 | import json 4 | import time 5 | import re 6 | from bs4 import BeautifulSoup 7 | from json.decoder import JSONDecodeError 8 | 9 | cookie = '' # 配置你的cookie 10 | sckey = '' # 配置你的server酱SCKEY 11 | bid = 'BV1mD4y1U7z9' # 配置需观看的视频BV号 12 | 13 | uid=re.match('(?<=DedeUserID=).*?(?=;)',cookie) 14 | sid=re.match('(?<=sid=).*?(?=;)',cookie) 15 | csrf=re.match('(?<=bili_jct=).*',cookie) 16 | 17 | 18 | # bv转av 19 | def bv_to_av(bv): 20 | headers={ 21 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36', 22 | } 23 | r = requests.get('https://api.bilibili.com/x/web-interface/view', {'bvid': bv}, headers=headers) 24 | response = decode_json(r) 25 | try: 26 | return str(response['data']['aid']) 27 | except (KeyError, TypeError): 28 | return '883409884' 29 | 30 | # json解析 31 | def decode_json(r): 32 | try: 33 | response = r.json() 34 | except JSONDecodeError: 35 | # 虽然用的是requests的json方法,但要捕获的这个异常来自json模块 36 | return -1 37 | else: 38 | return response 39 | 40 | 41 | # server酱 42 | def pushinfo(info,specific): 43 | headers={ 44 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36', 45 | 'ContentType': 'text/html' 46 | } 47 | requests.session().get("https://sc.ftqq.com/"+sckey+".send?text=" + info + "&desp=" + specific,headers=headers) 48 | 49 | # 登录 50 | def login(): 51 | headers={ 52 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36', 53 | 'Cookie':cookie 54 | } 55 | response = requests.session().get('http://api.bilibili.com/x/space/myinfo',headers=headers) 56 | rejson = json.loads(response.text) 57 | code = rejson['code'] 58 | msg = rejson['message'] 59 | if code == 0: 60 | print('登录成功') 61 | return True 62 | else: 63 | print('登录失败:'+msg) 64 | return False 65 | 66 | # 获取用户信息 67 | def get_user_info(): 68 | headers = { 69 | 'Cookie':cookie 70 | } 71 | response = requests.session().get('http://api.bilibili.com/x/space/myinfo?jsonp=jsonp',headers=headers) 72 | rejson = json.loads(response.text) 73 | code = rejson['code'] 74 | msg = rejson['message'] 75 | if code == 0: 76 | userInfo=['账号:'+str(rejson['data']['silence']), 77 | '硬币:'+str(rejson['data']['coins']), 78 | '经验:'+str(rejson['data']['level_exp']['current_exp'])+"/"+str(rejson['data']['level_exp']['next_exp']), 79 | '等级:'+str(rejson['data']['level']), 80 | '昵称:'+str(rejson['data']['name']) 81 | ] 82 | print(userInfo[0]) 83 | print (userInfo[1]) 84 | print(userInfo[2]) 85 | #response['data']['face'] #头像 86 | print(userInfo[3]) 87 | print(userInfo[4]) 88 | return userInfo 89 | else: 90 | print("用户信息获取失败:"+msg) 91 | return "用户信息获取失败:"+msg 92 | 93 | # 直播签到 94 | def do_sign(): 95 | headers = { 96 | 'Cookie':cookie 97 | } 98 | response = requests.session().get('https://api.live.bilibili.com/sign/doSign',headers=headers) 99 | rejson = json.loads(response.text) 100 | code = rejson['code'] 101 | msg = rejson['message'] 102 | 103 | if code == 0: 104 | print('直播签到成功!') 105 | return True 106 | else: 107 | print("直播签到失败:"+msg) 108 | return False 109 | 110 | # 看视频 111 | def watch(): 112 | aid=bv_to_av(bid) 113 | headers = { 114 | 'Cookie':cookie 115 | } 116 | response = requests.session().get('http://api.bilibili.com/x/web-interface/view?aid='+str(aid),headers=headers) 117 | rejson = json.loads(response.text) 118 | code = rejson['code'] 119 | #print(response.text) 120 | if code == 0: 121 | cid = rejson['data']['cid'] 122 | duration = rejson['data']['duration'] 123 | else: 124 | print('视频信息解析失败') 125 | return False 126 | payload = { 127 | 'aid': aid, 128 | 'cid': cid, 129 | 'jsonp': "jsonp", 130 | 'mid': uid, 131 | 'csrf': csrf, 132 | 'played_time': 0, 133 | 'pause': False, 134 | 'realtime': duration, 135 | 'dt': 7, 136 | 'play_type': 1, 137 | 'start_ts': int(time.time()), 138 | } 139 | response = requests.session().post('http://api.bilibili.com/x/report/web/heartbeat',data=payload,headers=headers) 140 | rejson = json.loads(response.text) 141 | code = rejson['code'] 142 | if code == 0: 143 | time.sleep(5) 144 | payload['played_time'] = duration - 1 145 | payload['play_type'] = 0 146 | payload['start_ts'] = int(time.time()) 147 | response = requests.session().post('http://api.bilibili.com/x/report/web/heartbeat',data=payload,headers=headers) 148 | rejson = json.loads(response.text) 149 | code = rejson['code'] 150 | if code == 0: 151 | print(f"av{aid}观看成功") 152 | return True 153 | print(f"av{aid}观看失败 {response}") 154 | return False 155 | 156 | 157 | 158 | def main(*args): 159 | if login(): 160 | ui = get_user_info() 161 | desp='直播签到:'+str(do_sign())+'\n\n'+'观看视频:'+str(watch())+'\n\n'+ui[0]+'\n\n'+ui[1]+'\n\n'+ui[2]+'\n\n'+ui[3]+'\n\n'+ui[4]+'\n\n' 162 | pushinfo('哔哩哔哩签到成功',desp) 163 | else: 164 | pushinfo('哔哩哔哩签到失败','') 165 | 166 | 167 | 168 | if __name__ == '__main__': 169 | main() -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # 项目简介 2 | 3 |   腾讯云SCF(云函数)、Github Actions的python脚本,用于每天自动签到,一个是吾爱破解论坛的一个是哔哩哔哩的,作为我了解SCF的示例。 4 | 5 | # 功能实现 6 | 7 | ## 52pojieCheckIn 8 | - 【已完成】每日签到 9 | 10 | ## BilibiliCheckIn 11 | - 【已完成】每日直播签到赚银瓜子 12 | - 【已完成】每日观看视频赚经验 13 | - 【已完成】每日登录赚经验 14 | --- 15 | - 【未完成】每日分享赚经验 16 | 17 | >  客户端分享API: 18 | >``` 19 | >https://app.bilibili.com/x/v2/view/share/click 20 | >https://app.bilibili.com/x/v2/view/share/complete 21 | >``` 22 | >  网页端分享API: 23 | >``` 24 | >https://api.bilibili.com/x/web-interface/share/add 25 | >``` 26 | >  这两个接口貌似都能完成`客户端分享视频`的任务,但是以`Cookie`登录却无法完成,可能需要`access_key`,那就必须使用账号密码登录来获取,而使用`账号密码`登录就容易出现验证,参考了多个项目的实现方式,发现都是针对图形验证码的,而我测试的时候要么是手机验证要么是滑块验证(就很玄学),这对于`SCF`来说不太适合。水平有限,如果你有适合`SCF`的解决方法麻烦提一个`issue`或`Pr`,感谢。 27 | 28 | - 【未完成】每日投币赚经验 29 | 30 | >  可以完成但没必要,不投,要白嫖经验!如果你需要的话,请使用`https://api.bilibili.com/x/web-interface/coin/add`这个接口,提交参数为`aid`、`multiply`、`cross_domain`、`csrf` 31 | 32 | 33 | # 项目结构 34 | 35 | | 文件 | 描述 | 36 | | :----: | :----: | 37 | | 52pojieCheckIn.py | 吾爱破解论坛 | 38 | | BilibiliCheckIn.py | 哔哩哔哩 | 39 | | bs4.zip | python3依赖包 | 40 | 41 | # 使用说明 42 | 43 | ## 注意事项 44 | 45 |   吾爱破解论坛的签到有点奇怪,没研究是啥问题引起的,有时可以正常签到有时又提示:不是进行中的任务,可以尝试循环签到几次(反正我是这么解决的,哈哈哈),知道原因的同学麻烦发个Pr,感谢。 46 | 47 | ## 获取Cookie 48 | 49 |   打开浏览器,按F12,在Network处查找,还不会的话请自行百度! 50 | 51 | ## Server酱 52 | 53 |   可选,用于消息反馈,如需使用其他同类型产品,修改一下`pushinfo`函数就行。 官网:http://sc.ftqq.com/3.version 54 | 55 | ## 腾讯云SCF(云函数) 56 | 57 | 1. 复制代码至`云函数`,保存文件名为`index.py` 58 | 2. `执行方法`设置为`index.main` 59 | 3. 新建`层`,上传依赖包`bs4` 60 | 4. 在`层管理`绑定刚刚新建的`层` 61 | 5. 测试成功后在`触发管理`里设置触发器 62 | 63 | # 参考资料 64 | 65 | 感谢: 66 | 67 | https://github.com/Hsury/Bilibili-Toolkit 68 | https://github.com/shniubobo/bilibili_bv2av -------------------------------------------------------------------------------- /bs4.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1gcat/ExampleForSCF/1e8e40d51bf788c3c2260643de11a101fe7097c9/bs4.zip --------------------------------------------------------------------------------