Skip to content

Commit

Permalink
🔨 Refactor 12 scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Oreomeow committed Oct 13, 2022
1 parent 750e122 commit 0bcdb7c
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 183 deletions.
22 changes: 10 additions & 12 deletions ck_baidu_url_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
new Env('百度搜索资源平台');
"""

from urllib import parse
from urllib.parse import parse_qs, urlsplit

import requests

Expand All @@ -18,17 +18,17 @@ def __init__(self, check_items):

@staticmethod
def url_submit(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)
site = parse_qs(urlsplit(submit_url).query).get("site", [])[0]
urls_data = requests.get(data_url)
remain = 100000
success_count = 0
error_count = 0
for _ in range(times):
try:
response = requests.post(url=submit_url, data=urls_data)
if response.json().get("success"):
remain = response.json().get("remain")
success_count += response.json().get("success")
res = requests.post(submit_url, data=urls_data).json()
if res.get("success"):
remain = res.get("remain")
success_count += res.get("success")
else:
error_count += 1
except Exception as e:
Expand All @@ -49,9 +49,7 @@ def main(self):
submit_url = check_item.get("submit_url")
times = int(check_item.get("times", 100))
if data_url and submit_url:
msg = self.url_submit(
data_url=data_url, submit_url=submit_url, times=times
)
msg = self.url_submit(data_url, submit_url, times)
else:
msg = "配置错误"
msg_all += msg + "\n\n"
Expand All @@ -61,5 +59,5 @@ def main(self):
if __name__ == "__main__":
_data = get_data()
_check_items = _data.get("BAIDU", [])
res = BaiduUrlSubmit(check_items=_check_items).main()
send("百度搜索资源平台", res)
result = BaiduUrlSubmit(check_items=_check_items).main()
send("百度搜索资源平台", result)
42 changes: 22 additions & 20 deletions ck_cloud189.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ def login(self, session, username, password):
"https://cloud.189.cn/api/portal/loginUrl.action?"
"redirectURL=https://cloud.189.cn/web/redirect.html"
)
r = session.get(url=url)
captchatoken = re.findall(r"captchaToken' value='(.+?)'", r.text)[0]
lt = re.findall(r'lt = "(.+?)"', r.text)[0]
returnurl = re.findall(r"returnUrl = '(.+?)'", r.text)[0]
paramid = re.findall(r'paramId = "(.+?)"', r.text)[0]
j_rsakey = re.findall(r'j_rsaKey" value="(\S+)"', r.text, re.M)[0]
session.headers.update({"lt": lt})
res = session.get(url).text
captchatoken = re.findall(r"captchaToken' value='(.+?)'", res)[0]
lt = re.findall(r'lt = "(.+?)"', res)[0]
returnurl = re.findall(r"returnUrl = '(.+?)'", res)[0]
paramid = re.findall(r'paramId = "(.+?)"', res)[0]
j_rsakey = re.findall(r'j_rsaKey" value="(\S+)"', res, re.M)[0]

session.headers.update({"lt": lt})
username = self.rsa_encode(j_rsakey, username)
password = self.rsa_encode(j_rsakey, password)
url = "https://open.e.189.cn/api/logbox/oauth2/loginSubmit.do"
Expand All @@ -92,16 +92,16 @@ def login(self, session, username, password):
"mailSuffix": "@189.cn",
"paramId": paramid,
}
r = session.post(url, data=data, headers=headers, timeout=5)
if r.json()["result"] != 0:
return "登陆状态: " + r.json()["msg"]
redirect_url = r.json()["toUrl"]
session.get(url=redirect_url)
res = session.post(url, data=data, headers=headers, timeout=5).json()
if res["result"] != 0:
return "登陆状态: " + res["msg"]
redirect_url = res["toUrl"]
session.get(redirect_url)
return True

@staticmethod
def sign(session):
rand = str(round(time.time() * 1000))
rand = round(time.time() * 1000)
surl = (
f"https://api.cloud.189.cn/mkt/userSign.action?"
f"rand={rand}&clientType=TELEANDROID&version=8.6.3&model=SM-G930K"
Expand All @@ -124,28 +124,30 @@ def sign(session):
"Host": "m.cloud.189.cn",
"Accept-Encoding": "gzip, deflate",
}
response = session.get(url=surl, headers=headers)
response = session.get(surl, headers=headers)
netdiskbonus = response.json().get("netdiskBonus")
if response.json().get("isSign") == "false":
msg = f"签到结果: 未签到,签到获得 {netdiskbonus}M 空间"
else:
msg = f"签到结果: 已经签到过了,签到获得 {netdiskbonus}M 空间"
response = session.get(url=url, headers=headers)

response = session.get(url, headers=headers)
if "errorCode" in response.text:
msg += f"\n第一次抽奖: {response.json().get('errorCode')}"
else:
description = response.json().get("description", "")
if description in ["1", 1]:
description = "50M 空间"
msg += f"\n第一次抽奖: 获得{description}"
response = session.get(url=url2, headers=headers)
msg += f"\n第一次抽奖: 获得 {description}"

response = session.get(url2, headers=headers)
if "errorCode" in response.text:
msg += f"\n第二次抽奖: {response.json().get('errorCode')}"
else:
description = response.json().get("description", "")
if description in ["1", 1]:
description = "50M 空间"
msg += f"\n第二次抽奖: 获得{description}"
msg += f"\n第二次抽奖: 获得 {description}"
return msg

def main(self):
Expand All @@ -154,8 +156,8 @@ def main(self):
phone = check_item.get("phone")
password = check_item.get("password")
session = requests.Session()
flag = self.login(session=session, username=phone, password=password)
sign_msg = self.sign(session=session) if flag is True else flag
flag = self.login(session, phone, password)
sign_msg = self.sign(session) if flag is True else flag
msg = f"帐号信息: *******{phone[-4:]}\n{sign_msg}"
msg_all += msg + "\n\n"
return msg_all
Expand Down
10 changes: 5 additions & 5 deletions ck_csdn.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, check_items):

def sign(self, cookies):
url = "https://me.csdn.net/api/LuckyDraw_v2/signIn"
res = requests.get(url=url, headers=self.headers, cookies=cookies).json()
res = requests.get(url, headers=self.headers, cookies=cookies).json()
if res.get("code") == 200:
msg = res.get("data").get("msg")
else:
Expand All @@ -31,14 +31,14 @@ def sign(self, cookies):

def draw(self, cookies):
url = "https://me.csdn.net/api/LuckyDraw_v2/goodluck"
res = requests.get(url=url, headers=self.headers, cookies=cookies).json()
res = requests.get(url, headers=self.headers, cookies=cookies).json()
if res.get("code") == 200:
return (
f", {res.get('data').get('prize_title')}"
if res.get("data").get("prize_title") is not None
else f"{res.get('data').get('msg')}"
)
return "抽奖失败\n"
return "抽奖失败"

def main(self):
msg_all = ""
Expand All @@ -52,8 +52,8 @@ def main(self):
except Exception as e:
print(f"获取用户信息失败: {e}")
user_name = "未获取到用户信息"
sign_msg = self.sign(cookies=cookie)
draw_msg = self.draw(cookies=cookie)
sign_msg = self.sign(cookie)
draw_msg = self.draw(cookie)
msg = f"帐号信息: {user_name}\n签到信息: {sign_msg}\n抽奖结果: {draw_msg}"
msg_all += msg + "\n\n"
return msg_all
Expand Down
2 changes: 1 addition & 1 deletion ck_enshan.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def main(self):
msg_all = ""
for i, check_item in enumerate(self.check_items, start=1):
cookie = str(check_item.get("cookie"))
msg = f"账号{i}\n------ 签到结果 ------\n{self.sign(cookie=cookie)}"
msg = f"账号{i}\n------ 签到结果 ------\n{self.sign(cookie)}"
time.sleep(1)
msg_all += msg + "\n\n"
return msg_all
Expand Down
19 changes: 6 additions & 13 deletions ck_everphoto.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
new Env('时光相册');
"""

import json

import requests

from notify_mtr import send
Expand All @@ -31,27 +29,22 @@ def main(self):
"user-agent": "EverPhoto/4.5.0 (Android;4050002;MuMu;23;dev)",
"application": "tc.everphoto",
}

login_res = requests.post(login_url, data=login_key, headers=header)
login_data = json.loads(login_res.text)["data"]
data = requests.post(login_url, login_key, headers=header).json()["data"]

header = {
"user-agent": "EverPhoto/4.5.0 (Android;4050002;MuMu;23;dev)",
"application": "tc.everphoto",
"content-type": "application/json",
"host": "openapi.everphoto.cn",
"connection": "Keep-Alive",
"authorization": "Bearer " + login_data["token"],
"authorization": f'Bearer {data["token"]}',
}

response = requests.post(url, headers=header)
data = json.loads(response.text)
checkin_result = data["data"]["checkin_result"]
continuity = data["data"]["continuity"]
res = requests.post(url, headers=header).json()
checkin_result = res["data"]["checkin_result"]
continuity = res["data"]["continuity"]

msg = (
f"是否为今日第一次签到:{str(checkin_result)}" + "\n" + "累积签到天数:" + str(continuity)
)
msg = f"是否为今日第一次签到:{checkin_result}\n累积签到天数:{continuity}"
msg_all += msg + "\n\n"
return msg_all

Expand Down
31 changes: 12 additions & 19 deletions ck_fmapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
new Env('Fa米家');
"""

import json

import requests

from notify_mtr import send
Expand All @@ -22,9 +20,8 @@ def sign(headers):
url = (
"https://fmapp.chinafamilymart.com.cn/api/app/market/member/signin/sign"
)
res = requests.post(url=url, headers=headers).json()
code = res.get("code")
if code == "200":
res = requests.post(url, headers=headers).json()
if res.get("code") == "200":
data = res.get("data", {})
msg = (
f"再坚持 {data.get('nextDay')} 天即可获得 {data.get('nextNumber')} 个发米粒\n"
Expand All @@ -34,18 +31,16 @@ def sign(headers):
msg = res.get("message")
except Exception as e:
print("错误信息", e)
msg = f"未知错误:{str(e)}"
msg = f"未知错误:{e}"
return msg

@staticmethod
def user_info(headers):
try:
url = "https://fmapp.chinafamilymart.com.cn/api/app/member/info"
res = requests.post(url=url, headers=headers).json()
code = res.get("code")
if code == "200":
data = res.get("data", {})
msg = data.get("nickName")
res = requests.post(url, headers=headers).json()
if res.get("code") == "200":
msg = res.get("data", {}).get("nickName")
else:
msg = res.get("message")
except Exception as e:
Expand All @@ -58,12 +53,10 @@ def mili_count(headers):
try:
url = "https://fmapp.chinafamilymart.com.cn/api/app/member/v1/mili/service/detail"
res = requests.post(
url=url, headers=headers, data=json.dumps({"pageSize": 10, "pageNo": 1})
url, headers=headers, json={"pageSize": 10, "pageNo": 1}
).json()
code = res.get("code")
if code == "200":
data = res.get("data", {})
msg = data.get("miliNum")
if res.get("code") == "200":
msg = res.get("data", {}).get("miliNum")
else:
msg = res.get("message")
except Exception as e:
Expand Down Expand Up @@ -96,9 +89,9 @@ def main(self):
"cookie": cookie,
"blackBox": blackbox,
}
sign_msg = self.sign(headers=headers)
name_msg = self.user_info(headers=headers)
mili_msg = self.mili_count(headers=headers)
sign_msg = self.sign(headers)
name_msg = self.user_info(headers)
mili_msg = self.mili_count(headers)
msg = f"帐号信息: {name_msg}\n签到状态: {sign_msg}\n米粒数量: {mili_msg}"
msg_all += msg + "\n\n"
return msg_all
Expand Down
10 changes: 3 additions & 7 deletions ck_freenom.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,13 @@ def _login(self, usr: str, pwd: str) -> bool:
def main(self) -> str:
msg = ""
msg_all = ""
i = 0

for check_item in self.check_items:
i += 1
for i, check_item in enumerate(self.check_items, start=1):
username = check_item.get("username")
password = check_item.get("password")

# login
ok = self._login(usr=username, pwd=password)
if not ok:
if not self._login(usr=username, pwd=password):
msg_all += f"account{i} login failed\n\n"
continue

Expand All @@ -91,8 +88,7 @@ def main(self) -> str:
# renew domains
res = ""
for domain, days, renewal_id in domains:
days = int(days)
if days < 14:
if int(days) < 14:
self._s.headers.update(
{
"referer": f"https://my.freenom.com/domains.php?a=renewdomain&domain={renewal_id}",
Expand Down
2 changes: 1 addition & 1 deletion ck_game163.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def main(self):
msg_all = ""
for check_item in self.check_items:
authorization = str(check_item.get("authorization"))
msg = self.checkin(authorization=authorization)
msg = self.checkin(authorization)
msg_all += msg + "\n\n"
return msg_all

Expand Down
Loading

0 comments on commit 0bcdb7c

Please sign in to comment.