Merge branch 'master' into develop

This commit is contained in:
liulong 2024-09-29 17:56:08 +08:00
commit 67b47964f8

202
hykb.py
View File

@ -4,17 +4,23 @@
# @author Echo # @author Echo
# @EditTime 2024/9/20 # @EditTime 2024/9/20
import os import os
import random
import re import re
import threading
import urllib.parse
from datetime import datetime from datetime import datetime
import httpx
import requests import requests
import random
from sendNotify import send_notification_message from sendNotify import send_notification_message
if 'Hykb_cookie' in os.environ: if 'Hykb_cookie' in os.environ:
Hykb_cookie = re.split("@", os.environ.get("Hykb_cookie")) Hykb_cookie = re.split("@", os.environ.get("Hykb_cookie"))
else: else:
Hykb_cookie = [] Hykb_cookie = [
"1|0|128421985|5b+r54iG55So5oi3MTI4NDIxOTg1|kbA25014349F11473F467DC6FF5C89E9D6|plcAoJ6jITDlGvEnGl80IlfuoREWIlVjITZOpv6U7WI=%1|5312899df0a922f9707df9a5ad8dee37"
]
print("未查找到Hykb_cookie变量.") print("未查找到Hykb_cookie变量.")
@ -22,16 +28,30 @@ class HaoYouKuaiBao():
"""好游快爆签到 """好游快爆签到
""" """
def __init__(self, cookie, user_agent): def __init__(self, cookie):
self.client = httpx.Client(
verify=False,
headers={
"Origin": "https://huodong3.i3839.com",
"Referer": "https://huodong3.3839.com/n/hykb/cornfarm/index.php?imm=0",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
}
)
self.cookie = cookie self.cookie = cookie
self.url = "https://huodong3.3839.com/n/hykb/{}/ajax{}.php" self.url = "https://huodong3.3839.com/n/hykb/{}/ajax{}.php"
self.data = "ac={}&r=0.{}&scookie={}" self.user_name = self.user_info()["user"]
self.headers = {
"Origin": "https://huodong3.i3839.com", def get_index_html(self):
"Referer": "https://huodong3.3839.com/n/hykb/cornfarm/index.php?imm=0", """
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", 获取首页
"User-Agent": user_agent :return:
} """
url = "https://huodong3.3839.com/n/hykb/cornfarm/index.php?imm=0"
try:
response = self.client.get(url)
return response.text
except Exception as e:
print("好游快爆-获取首页出现错误:{}".format(e))
def user_info(self): def user_info(self):
""" """
@ -39,18 +59,13 @@ class HaoYouKuaiBao():
:return: :return:
""" """
url = self.url.format("qdjh", "") url = self.url.format("qdjh", "")
data = { payload = f"ac=login&r=0.{random.randint(100000000000000000, 899999999999999999)}&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6"
"ac": "login",
"r": f"0.{random.randint(1000000000000000, 8999999999999999)}",
"scookie": self.cookie,
"device": "kbA25014349F11473F467DC6FF5C89E9D6"
}
try: try:
response = requests.post(url, headers=self.headers, data=data).json() response = self.client.post(url, content=payload).json()
if response['key'] == 'ok': if response['key'] == 'ok':
return { return {
"user": response["config"]["name"], "user": response["config"]["name"],
"uuid": response["config"]["uuid"] "uuid": response["config"]["uid"]
} }
except Exception as e: except Exception as e:
print("好游快爆-获取用户信息出现错误:{}".format(e)) print("好游快爆-获取用户信息出现错误:{}".format(e))
@ -59,24 +74,24 @@ class HaoYouKuaiBao():
"""播种 """播种
""" """
url = self.url.format("cornfarm", "_plant") url = self.url.format("cornfarm", "_plant")
data = self.data.format("Plant", random.randint(1000000000000000, 8999999999999999), self.cookie) payload = f"ac=Plant&r=0.{random.randint(100000000000000000, 899999999999999999)}&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6"
try: try:
response = requests.post(url, headers=self.headers, data=data).json() response = self.client.post(url, content=payload).json()
if response['key'] == 'ok': if response['key'] == 'ok':
print("好游快爆-播种成功") print(f"好游快爆-用户【{self.user_name}播种成功")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
"好游快爆-播种成功") f"好游快爆-用户【{self.user_name}播种成功")
return 1 return 1
else: else:
if response['seed'] == 0: if response['seed'] == 0:
print("好游快爆-种子已用完") print(f"好游快爆-用户【{self.user_name}种子已用完")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
"好游快爆-种子已用完") f"好游快爆-用户【{self.user_name}种子已用完")
return -1 return -1
else: else:
print("好游快爆-播种失败") print(f"好游快爆-用户【{self.user_name}播种失败")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
"好游快爆-播种失败") f"好游快爆-用户【{self.user_name}播种失败")
return 0 return 0
except Exception as e: except Exception as e:
print(f"好游快爆-播种出现错误:{e}") print(f"好游快爆-播种出现错误:{e}")
@ -86,18 +101,21 @@ class HaoYouKuaiBao():
"""收获 """收获
""" """
url = self.url.format("cornfarm", "_plant") url = self.url.format("cornfarm", "_plant")
data = self.data.format("Harvest", random.randint(1000000000000000, 8999999999999999), self.cookie) payload = f"ac=Harvest&r=0.{random.randint(100000000000000000, 899999999999999999)}&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6"
try: try:
response = requests.post(url, headers=self.headers, data=data).json() response = self.client.post(url, content=payload).json()
if response['key'] == 'ok': if response['key'] == 'ok':
print("好游快爆-收获成功") print(f"好游快爆-用户【{self.user_name}收获成功")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
"好游快爆-收获成功") f"好游快爆-用户【{self.user_name}】收获成功")
return True elif response['key'] == '503':
print(f"好游快爆-用户【{self.user_name}{response['info']}")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
f"好游快爆-用户【{self.user_name}{response['info']}")
else: else:
print("好游快爆-收获失败") print(f"好游快爆-用户【{self.user_name}收获失败")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
"好游快爆-收获失败") f"好游快爆-用户【{self.user_name}收获失败")
return False return False
except Exception as e: except Exception as e:
print(f"好游快爆-收获出现错误:{e}") print(f"好游快爆-收获出现错误:{e}")
@ -107,33 +125,31 @@ class HaoYouKuaiBao():
"""登录 """登录
""" """
url = self.url.format("cornfarm", "") url = self.url.format("cornfarm", "")
data = self.data.format("login", random.randint(100000000000000, 8999999999999999), self.cookie) payload = f"ac=login&r=0.{random.randint(100000000000000000, 899999999999999999)}&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6"
response = requests.post(url, headers=self.headers, data=data) response = self.client.post(url, content=payload)
try: try:
response = response.json() response = response.json()
return response return response
except Exception as e: except Exception as e:
print("好游快爆-登录出现错误:{}".format(e)) print("好游快爆-登录出现错误:{}".format(e))
# response = response.text
# return response
def watering(self): def watering(self):
"""浇水 """浇水
""" """
url = self.url.format("cornfarm", "_sign") url = self.url.format("cornfarm", "_sign")
data = self.data.format("Sign&verison=1.5.7.005&OpenAutoSign=", payload = f"ac=Sign&verison=1.5.7.005&OpenAutoSign=&r=0.{random.randint(100000000000000000, 899999999999999999)}&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6"
random.randint(100000000000000, 8999999999999999), self.cookie)
try: try:
response = requests.post(url, headers=self.headers, data=data).json() response = self.client.post(url, content=payload).json()
if response['key'] == 'ok': if response['key'] == 'ok':
print("好游快爆-浇水成功") print(f"好游快爆-用户【{self.user_name}浇水成功")
send_notification_message(title="好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), send_notification_message(title="好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
content="好游快爆-浇水成功") content=f"好游快爆-用户【{self.user_name}浇水成功")
return 1, response['add_baomihua'] return 1, response['add_baomihua']
elif response['key'] == '1001': elif response['key'] == '1001':
print("好游快爆-今日已浇水") print(f"好游快爆-用户【{self.user_name}今日已浇水")
send_notification_message(title="好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), send_notification_message(title="好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
content="好游快爆-今日已浇水") content=f"好游快爆-用户【{self.user_name}今日已浇水")
return 0, 0 return 0, 0
else: else:
print("好游快爆-浇水出现错误:{}".format(response)) print("好游快爆-浇水出现错误:{}".format(response))
@ -142,24 +158,82 @@ class HaoYouKuaiBao():
print("好游快爆-浇水出现错误:{}".format(e)) print("好游快爆-浇水出现错误:{}".format(e))
return -1, 0 return -1, 0
# def buyseeds(self): def get_goods(self):
# """购买种子 """
# """ 获取商品id
# url = self.url.format("bmhstore2/inc/virtual", "Virtual") :return:
# print(url) """
# ac = "exchange&t=" + datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + "&goodsid=14565" response = self.client.post(
# data = self.data.format(ac, random.randint(100000000000000, 8999999999999999), self.cookie) url="https://shop.3839.com/index.php?c=Index&a=initCard",
# print(data) content=f"pid=1660&r=0.{random.randint(100000000000000000, 899999999999999999)}&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6"
# response = requests.post(url, headers=self.headers, data=data) )
# print(response.json()) try:
j_response = response.json()
if j_response['code'] == 200:
return j_response['data']['store_id'], j_response['data']['product_name']
except Exception as e:
print("好游快爆-获取商品id出现错误{}".format(e))
def buy_seeds(self):
"""购买种子
"""
# 获取种子商品id
goods_id, goods_name = self.get_goods()
print(goods_id, goods_name)
headers = {
# 'User-Agent': "Mozilla/5.0 (Linux; Android 12; Redmi K30 Pro Build/SKQ1.211006.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/96.0.4664.104 Mobile Safari/537.36Androidkb/1.5.7.507(android;Redmi K30 Pro;12;1080x2356;WiFi);@4399_sykb_android_activity@",
# 'Accept': "application/json, text/javascript, */*; q=0.01",
# 'Accept-Encoding': "gzip, deflate",
# 'X-Requested-With': "XMLHttpRequest",
'Content-Type': "application/x-www-form-urlencoded; charset=UTF-8",
'Origin': "https://huodong3.3839.com",
# 'Sec-Fetch-Site': "same-origin",
# 'Sec-Fetch-Mode': "cors",
# 'Sec-Fetch-Dest': "empty",
# 'Referer': "https://huodong3.3839.com/n/hykb/bmhstore2/inc/virtual/index.php?gid=14403&jtype=1",
# 'Accept-Language': "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
# 'Cookie': "cornfarm_iback_v5=ok; Hm_lvt_f1fb60d2559a83c8fa1ee6125a352bd7=1726835084; HMACCOUNT=A31622759CFC8814; friend_iback_v5=ok; cornfarm_shop_v1=ok; Birthday_btn_v1=ok; UM_distinctid=1921fb977e97c-0d88697ab29ace-6c074671-53c31-1921fb977ea7e; cornfarm_moren_btn_v1=ok; Hm_lpvt_f1fb60d2559a83c8fa1ee6125a352bd7=1727595549"
}
url = "https://huodong3.3839.com/n/hykb/bmhstore2/inc/virtual/ajaxVirtual.php"
# payload = f"ac=login&gid=14403&t=2024-09-29+15%3A39%3A33&r=0.4950858317265687&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6"
payload = "ac=login&gid=14403&t=2024-09-29+15%3A39%3A33&r=0.4950858317265687&scookie=1%7C0%7C128421985%7C5b%2Br54iG55So5oi3MTI4NDIxOTg1%7CkbA25014349F11473F467DC6FF5C89E9D6%7CplcAoJ6jITDlGvEnGl80IlfuoREWIlVjITZOpv6U7WI%3D%251%7C5312899df0a922f9707df9a5ad8dee37&device=kbA25014349F11473F467DC6FF5C89E9D6"
l_response = requests.post(
url=url,
headers=headers,
data=payload,
verify=False
# content=f"ac=login&t={datetime.now().strftime('%Y-%m-%d %H:%M:%S')}&r=0.{random.randint(100000000000000000, 899999999999999999)}&gid={goods_id}&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6"
).json()
if l_response['key'] != "ok":
print("好游快爆-购买种子出现错误:{}".format(l_response))
return False
else:
# 购买种子
response = self.client.post(
url="https://huodong3.3839.com/n/hykb/bmhstore2/inc/virtual/ajaxVirtual.php",
content=f"ac=exchange&t={datetime.now().strftime('%Y-%m-%d %H:%M:%S')}&r=0.{random.randint(100000000000000000, 899999999999999999)}&goodsid={goods_id}&scookie={urllib.parse.quote(self.cookie)}&device=kbA25014349F11473F467DC6FF5C89E9D6"
)
try:
j_response = response.json()
print(j_response)
if j_response['key'] == 200:
print(f"好游快爆-用户【{self.user_name}】购买了【{goods_name}")
send_notification_message(title="好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
content=f"好游快爆-用户【{self.user_name}】购买了【{goods_name}")
return True
else:
print("好游快爆-购买种子失败:{}".format(j_response))
return False
except Exception as e:
print("好游快爆-购买种子出现错误:{}".format(e))
return False
def sgin(self): def sgin(self):
user_name = self.user_info()["user"]
info = "" info = ""
# 登录 # 登录
data = self.login() data = self.login()
if data['key'] == 'ok': if data['key'] == 'ok':
print(f"用户: {user_name} 登录成功!✅") print(f"用户: {self.user_name}登录成功!✅")
if data['config']['csd_jdt'] == "100%": if data['config']['csd_jdt'] == "100%":
# 收获 # 收获
if self.harvest(): if self.harvest():
@ -217,11 +291,11 @@ class HaoYouKuaiBao():
if __name__ == '__main__': if __name__ == '__main__':
user_agents = [ threads = []
"Mozilla/5.0 (Linux; Android 13; M2012K11AC Build/TKQ1.220829.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/115.0.5790.166 Mobile Safari/537.36Androidkb/1.5.7.005(android;M2012K11AC;13;1080x2320;WiFi);@4399_sykb_android_activity@", for cookie_ in Hykb_cookie:
"Mozilla/5.0 (Linux; Android 12; Redmi K30 Pro Build/SKQ1.211006.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/96.0.4664.104 Mobile Safari/537.36Androidkb/1.5.7.507(android;Redmi K30 Pro;12;1080x2356;WiFi);@4399_sykb_android_activity@" hykb = HaoYouKuaiBao(cookie_)
] thread = threading.Thread(target=hykb.buy_seeds)
for cookie_, user_agent in zip(Hykb_cookie, user_agents): threads.append(thread)
hykb = HaoYouKuaiBao(cookie_, user_agent) thread.start()
hykb.sgin() for thread in threads:
del hykb thread.join()