添加爱奇艺每日签到 & 百度站点每日提交

This commit is contained in:
Sitoi 2020-12-06 11:17:31 +08:00
parent 3fbbce7a7f
commit 5076e10491
12 changed files with 621 additions and 1 deletions

132
.gitignore vendored Normal file
View File

@ -0,0 +1,132 @@
# Created by .ignore support plugin (hsz.mobi)
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
.idea

100
README.md
View File

@ -1,2 +1,100 @@
# DailyCheckIn
# 每日签到集合
基于腾讯云函数的每日签到脚本
## 一、功能
- [x] [爱奇艺每日签到使用文档](./iqiyi/README.md): 签7天奖1天14天奖2天28天奖7天日常任务随机成长值
- [x] [百度站点每日提交使用文档](./baidu_url_submit/README.md): 每日提交网站页面供百度收录
## 二、使用
> 腾讯云函数使用(腾讯云函数相关教程请自行百度)
1. 根据各个使用文档获取对应的参数,并修改 `config.json`
2. 上传至【腾讯云函数】
3. 配置定时触发器
> 本地使用
1. 根据各个使用文档获取对应的参数,并修改 `config.json`
2. 运行 `index.py` 即可
> GitHub Action 使用
TODO
## 配置说明
配置文件:`config.json`
**示例**:
```json
{
"iqiyi": [
{
"iqyi_cookie": "QC005=5e8c9fd4e1235215c70796ebdfb1d944; QC142=zz_"
}
],
"BaiduUrlSubmit": [
{
"data_url": "https://cdn.jsdelivr.net/gh/Sitoi/Sitoi.github.io/baidu_urls.txt",
"submit_url": "http://data.zz.baidu.com/urls?site=https://sitoi.cn&token=bJIOyR1kxxxxxwu",
"times": 100
}
],
"dingtalk": {
"dingtalk_secret": "SECb7ee6efb290d5497fe1xxx38fd0aa1d18ae47",
"dingtalk_access_token": "c4eb939ba9e3xxx105448661ffb78eb8155e"
}
}
```
### dingtalk
钉钉推送配置信息
```json
{
"dingtalk_secret": "SECb7ee6efb290d5497fe1xxx38fd0aa1d18ae47",
"dingtalk_access_token": "c4eb939ba9e3xxx105448661ffb78eb8155e"
}
```
> 配置相关文档,请自行百度
- dingtalk_secret: 密钥
- dingtalk_access_token: 只需 `https://oapi.dingtalk.com/robot/send?access_token=XXX` 等于符号后面的 `XXX`
### iqiyi
> 支持多账号
```json
[
{
"iqyi_cookie": "QC005=5e8c9fd4e1235215c70796ebdfb1d944; QC142=zz_"
}
]
```
- iqyi_cookie: iqiyi 帐号的 cookie 信息
### BaiduUrlSubmit
> 支持多账号
```json
[
{
"data_url": "https://cdn.jsdelivr.net/gh/Sitoi/Sitoi.github.io/baidu_urls.txt",
"submit_url": "http://data.zz.baidu.com/urls?site=https://sitoi.cn&token=bJIOyR1kxxxxxwu",
"times": 100
}
]
```
- data_url: 获取待提交网站的 URL 链接
- submit_url: 提交百度网站的目标 URL
- times: 每日对同一个网站提交次数

View File

@ -0,0 +1,13 @@
# 百度站点每日提交
每日可提交次数为 100000 次 (好像每个人的每日可提交次数都不一样)
## 获取参数
![获取 submit_url 教程](./img/submit_url.png)
1. 登录[百度站点管理](https://ziyuan.baidu.com/site/index#/)
2. 点击普通收录
3. 复制 URL,该 URL 就是 `submit_url` 参数
4. 到你的博客项目中找到的自己需要提交的 URL 列表地址URL 列表地址就是 `data_url` 参数
参考:[https://cdn.jsdelivr.net/gh/Sitoi/Sitoi.github.io/baidu_urls.txt](https://cdn.jsdelivr.net/gh/Sitoi/Sitoi.github.io/baidu_urls.txt)

View File

@ -0,0 +1 @@
# -*- coding: utf-8 -*-

View File

@ -0,0 +1,78 @@
# -*- coding: utf-8 -*-
import base64
import hashlib
import hmac
import json
import os
import time
import urllib.parse
from urllib import parse
import requests
class BaiduUrlSubmit:
def __init__(self, dingtalk_secret, dingtalk_access_token, baidu_url_submit_list):
self.dingtalk_secret = dingtalk_secret
self.dingtalk_access_token = dingtalk_access_token
self.baidu_url_submit_list = baidu_url_submit_list
def message_to_dingtalk(self, content: str):
timestamp = str(round(time.time() * 1000))
secret_enc = self.dingtalk_secret.encode("utf-8")
string_to_sign = "{}\n{}".format(timestamp, self.dingtalk_secret)
string_to_sign_enc = string_to_sign.encode("utf-8")
hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
send_data = {"msgtype": "text", "text": {"content": content}}
requests.post(
url="https://oapi.dingtalk.com/robot/send?access_token={0}&timestamp={1}&sign={2}".format(
self.dingtalk_access_token, timestamp, sign
),
headers={"Content-Type": "application/json", "Charset": "UTF-8"},
data=json.dumps(send_data),
)
return content
def url_submit(self, data_url: str, submit_url: str, times: int = 100) -> str:
site = parse.parse_qs(parse.urlsplit(submit_url).query).get("site")[0]
urls_data = requests.get(url=data_url)
remian = 100000
success_count = 0
error_count = 0
for one in range(times):
response = requests.post(url=submit_url, data=urls_data)
if response.json().get("success"):
remian = response.json().get("remain")
success_count += response.json().get("success")
else:
error_count += 1
msg = (
f"【百度站点提交】\n站点地址: {site}\n当天剩余的可推送 url 条数: {remian}\n成功推送的 url 条数: {success_count}\n"
f"成功推送的 url 次数: {times - error_count}\n失败推送的 url 次数: {error_count}"
)
return msg
def main(self):
for baidu_url_submit in self.baidu_url_submit_list:
data_url = baidu_url_submit.get("data_url")
submit_url = baidu_url_submit.get("submit_url")
times = int(baidu_url_submit.get("times", 100))
if data_url and submit_url:
msg = self.url_submit(data_url=data_url, submit_url=submit_url, times=times)
print(msg)
if self.dingtalk_secret and self.dingtalk_access_token:
self.message_to_dingtalk(msg)
if __name__ == "__main__":
with open(os.path.join(os.path.dirname(os.path.dirname(__file__)), "config.json"), "r", encoding="utf-8") as f:
data = json.loads(f.read())
dingtalk_secret = data.get("dingtalk", {}).get("dingtalk_secret")
dingtalk_access_token = data.get("dingtalk", {}).get("dingtalk_access_token")
baidu_url_submit_list = data.get("BaiduUrlSubmit", [])
BaiduUrlSubmit(
dingtalk_secret=dingtalk_secret,
dingtalk_access_token=dingtalk_access_token,
baidu_url_submit_list=baidu_url_submit_list,
).main()

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

18
config.json Normal file
View File

@ -0,0 +1,18 @@
{
"dingtalk": {
"dingtalk_secret": "xxxx",
"dingtalk_access_token": "xxxx"
},
"iqiyi": [
{
"iqyi_cookie": "xxxx"
}
],
"BaiduUrlSubmit": [
{
"data_url": "https://cdn.jsdelivr.net/gh/Sitoi/Sitoi.github.io/baidu_urls.txt",
"submit_url": "xxxx",
"times": 100
}
]
}

34
index.py Normal file
View File

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# -*- coding: utf8 -*-
import json
from baidu_url_submit.baidu_url_submit import BaiduUrlSubmit
from iqiyi.iqiyi import IQIYICheckIn
def main_handler(event, context):
with open("config.json", "r", encoding="utf-8") as f:
data = json.loads(f.read())
dingtalk_secret = data.get("dingtalk", {}).get("dingtalk_secret")
dingtalk_access_token = data.get("dingtalk", {}).get("dingtalk_access_token")
iqiyi_cookie_list = data.get("iqiyi", [])
if iqiyi_cookie_list:
IQIYICheckIn(
dingtalk_secret=dingtalk_secret,
dingtalk_access_token=dingtalk_access_token,
iqiyi_cookie_list=iqiyi_cookie_list,
).main()
baidu_url_submit_list = data.get("BaiduUrlSubmit", [])
if baidu_url_submit_list:
BaiduUrlSubmit(
dingtalk_secret=dingtalk_secret,
dingtalk_access_token=dingtalk_access_token,
baidu_url_submit_list=baidu_url_submit_list,
).main()
return
if __name__ == '__main__':
main_handler(event=None, context=None)

22
iqiyi/README.md Normal file
View File

@ -0,0 +1,22 @@
# 爱奇艺每日签到
签 7天奖 1天14天奖 2天28天奖 7天日常任务随机成长值
- [x] 每日签到
- [x] 每日抽奖
- [x] 日常任务
## 获取 cookie 教程
![获取 cookie 教程](./img/iqiyi_cookie.png)
1. 进入[爱奇艺IQIYI官网](https://www.iqiyi.com/)
2. 按 `F12` 打开开发者工具,刷新页面
3. 点击 `Network` 标签
4. 选择 `Doc` 标签
5. 选中 `www.iqiyi.com`
6. 下滑找到 `cookie` 全选复制即可
## 配置 config.json
将获取到的 cookie 写入 config.json

1
iqiyi/__init__.py Normal file
View File

@ -0,0 +1 @@
# -*- coding: utf-8 -*-

BIN
iqiyi/img/iqiyi_cookie.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

223
iqiyi/iqiyi.py Normal file
View File

@ -0,0 +1,223 @@
# -*- coding: utf-8 -*-
import base64
import hashlib
import hmac
import json
import os
import re
import time
import urllib.parse
import requests
class IQIYICheckIn:
"""
爱奇艺签到抽奖做日常任务(签到任务仅限 VIP)
*奖励 7天奖 114天奖 228天奖 7日常任务随机成长值
"""
def __init__(self, dingtalk_secret, dingtalk_access_token, iqiyi_cookie_list):
self.dingtalk_secret = dingtalk_secret
self.dingtalk_access_token = dingtalk_access_token
self.iqiyi_cookie_list = iqiyi_cookie_list
self.task_list = []
self.growth_task = 0
def parse_cookie(self, cookie):
p00001 = re.findall(r"P00001=(.*?);", cookie)[0]
p00003 = re.findall(r"P00003=(.*?);", cookie)[0]
return p00001, p00003
def message_to_dingtalk(self, content):
timestamp = str(round(time.time() * 1000))
secret_enc = self.dingtalk_secret.encode("utf-8")
string_to_sign = "{}\n{}".format(timestamp, self.dingtalk_secret)
string_to_sign_enc = string_to_sign.encode("utf-8")
hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
send_data = {"msgtype": "text", "text": {"content": content}}
requests.post(
url="https://oapi.dingtalk.com/robot/send?access_token={0}&timestamp={1}&sign={2}".format(
self.dingtalk_access_token, timestamp, sign
),
headers={"Content-Type": "application/json", "Charset": "UTF-8"},
data=json.dumps(send_data),
)
return content
def user_information(self, p00001):
"""
用户信息查询
"""
time.sleep(3)
url = "http://serv.vip.iqiyi.com/vipgrowth/query.action"
params = {"P00001": p00001}
res = requests.get(url=url, params=params)
if res.json()["code"] == "A00000":
try:
res_data = res.json()["data"]
level = res_data["level"] # VIP 等级
growthvalue = res_data["growthvalue"] # 当前 VIP 成长值
distance = res_data["distance"] # 升级需要成长值
deadline = res_data["deadline"] # VIP 到期时间
today_growth_value = res_data["todayGrowthValue"] # 今日成长值
msg = (
f"VIP 等级: {level}\n当前成长值: {growthvalue}\n"
f"升级需成长值: {distance}\n今日成长值: +{today_growth_value}\nVIP 到期时间: {deadline}"
)
except Exception as e:
msg = res.json()
else:
msg = res.json()
return msg
def sign(self, p00001):
"""
VIP 签到
"""
url = "https://tc.vip.iqiyi.com/taskCenter/task/queryUserTask"
params = {"P00001": p00001, "autoSign": "yes"}
res = requests.get(url=url, params=params)
if res.json()["code"] == "A00000":
try:
growth = res.json()["data"]["signInfo"]["data"]["rewardMap"]["growth"]
continue_sign_days_sum = res.json()["data"]["signInfo"]["data"]["continueSignDaysSum"]
reward_day = (
7 if continue_sign_days_sum % 28 <= 7 else (14 if continue_sign_days_sum % 28 <= 14 else 28)
)
rouund_day = 28 if continue_sign_days_sum % 28 == 0 else continue_sign_days_sum % 28
msg = f"+{growth}成长值\n连续签到: {continue_sign_days_sum}\n签到周期: {rouund_day}天/{reward_day}"
except Exception as e:
msg = res.json()["data"]["signInfo"]["msg"]
else:
msg = res.json()["msg"]
return msg
def query_user_task(self, p00001):
"""
获取 VIP 日常任务 taskCode(任务状态)
"""
url = "https://tc.vip.iqiyi.com/taskCenter/task/queryUserTask"
params = {"P00001": p00001}
res = requests.get(url=url, params=params)
if res.json()["code"] == "A00000":
for item in res.json()["data"]["tasks"]["daily"]:
self.task_list.append(
{
"name": item["name"],
"taskCode": item["taskCode"],
"status": item["status"],
"taskReward": item["taskReward"]["task_reward_growth"],
}
)
return self
def join_task(self, p00001):
"""
遍历完成任务
"""
url = "https://tc.vip.iqiyi.com/taskCenter/task/joinTask"
params = {"P00001": p00001, "taskCode": "", "platform": "bb136ff4276771f3", "lang": "zh_CN"}
# 遍历任务,仅做一次
for item in self.task_list:
if item["status"] == 2:
params["taskCode"] = item["taskCode"]
res = requests.get(url=url, params=params)
# print(res.text)
def get_task_rewards(self, p00001):
"""
获取任务奖励
:return: 返回信息
"""
url = "https://tc.vip.iqiyi.com/taskCenter/task/getTaskRewards"
params = {"P00001": p00001, "taskCode": "", "platform": "bb136ff4276771f3", "lang": "zh_CN"}
for item in self.task_list:
if item["status"] == 0:
params["taskCode"] = item["taskCode"]
res = requests.get(url=url, params=params)
if res.json()["code"] == "A00000":
self.growth_task += item["taskReward"]
msg = f"+{self.growth_task}成长值"
return msg
def draw(self, draw_type, p00001, p00003):
"""
查询抽奖次数(),抽奖
:param draw_type: 类型0 查询次数1 抽奖
:return: {status, msg, chance}
"""
url = "https://iface2.iqiyi.com/aggregate/3.0/lottery_activity"
params = {
"lottery_chance": 1,
"app_k": "b398b8ccbaeacca840073a7ee9b7e7e6",
"app_v": "11.6.5",
"platform_id": 10,
"dev_os": "8.0.0",
"dev_ua": "FRD-AL10",
"net_sts": 1,
"qyid": "2655b332a116d2247fac3dd66a5285011102",
"psp_uid": p00003,
"psp_cki": p00001,
"psp_status": 3,
"secure_v": 1,
"secure_p": "GPhone",
"req_sn": round(time.time() * 1000),
}
if draw_type == 1:
del params["lottery_chance"]
res = requests.get(url=url, params=params)
if not res.json().get("code"):
chance = int(res.json().get("daysurpluschance"))
msg = res.json().get("awardName")
return {"status": True, "msg": msg, "chance": chance}
else:
try:
msg = res.json().get("kv", {}).get("msg")
except Exception as e:
msg = res.json()["errorReason"]
return {"status": False, "msg": msg, "chance": 0}
def main(self):
for iqiyi_cookie in self.iqiyi_cookie_list:
p00001, p00003 = self.parse_cookie(iqiyi_cookie.get("iqyi_cookie"))
# 签到
sign_msg = self.sign(p00001=p00001)
# 抽奖
chance = self.draw(0, p00001=p00001, p00003=p00003)["chance"]
if chance:
draw_msg = ""
for i in range(chance):
ret = self.draw(1, p00001=p00001, p00003=p00003)
draw_msg += ret["msg"] + ";" if ret["status"] else ""
else:
draw_msg = "抽奖机会不足"
# 日常任务
self.query_user_task(p00001=p00001).join_task(p00001=p00001)
task_msg = self.query_user_task(p00001=p00001).get_task_rewards(p00001=p00001)
# 查询用户信息
user_msg = self.user_information(p00001=p00001)
msg = (
f"【爱奇艺等级】\n{user_msg}\n-----------------------------\n"
f"【爱奇艺签到】\n签到奖励: {sign_msg}\n任务奖励: {task_msg}\n抽奖奖励: {draw_msg}"
)
print(msg)
if self.dingtalk_secret and self.dingtalk_access_token:
self.message_to_dingtalk(msg)
if __name__ == "__main__":
with open(os.path.join(os.path.dirname(os.path.dirname(__file__)), "config.json"), "r", encoding="utf-8") as f:
data = json.loads(f.read())
dingtalk_secret = data.get("dingtalk", {}).get("dingtalk_secret")
dingtalk_access_token = data.get("dingtalk", {}).get("dingtalk_access_token")
iqiyi_cookie_list = data.get("iqiyi", [])
IQIYICheckIn(
dingtalk_secret=dingtalk_secret,
dingtalk_access_token=dingtalk_access_token,
iqiyi_cookie_list=iqiyi_cookie_list,
).main()