更新 搜搜小亏_api.py
This commit is contained in:
parent
0b862bcb7d
commit
7e435ef51b
52
搜搜小亏_api.py
Normal file
52
搜搜小亏_api.py
Normal file
File diff suppressed because one or more lines are too long
436
搜搜小亏_api_1.4.py
436
搜搜小亏_api_1.4.py
@ -1,436 +0,0 @@
|
||||
# --------------------------------注释区--------------------------------
|
||||
# 入口:微信加
|
||||
# http://share.shangjiabao.vip/#/pages/redirect/index?params=%7B%22type%22%3A4%2C%22id%22%3A34026%2C%22date%22%3A%2220241103%22%2C%22channel%22%3A%22A0000004%22%7D
|
||||
#
|
||||
# 需抓取数据:
|
||||
# * 填写自动过检的api接口 本地 内网ip:5000 非本地自行进行穿透
|
||||
# * 登录多少个账号就跑多少个账号
|
||||
#
|
||||
#
|
||||
# 抓取请求头中的user-agent填入yuanshen_useragent 无论多少个号都只填一个即可!!!!
|
||||
#
|
||||
# 变量名:yuanshen_api
|
||||
#
|
||||
# --------------------------------祈求区--------------------------------
|
||||
# _ooOoo_
|
||||
# o8888888o
|
||||
# 88" . "88
|
||||
# (| -_- |)
|
||||
# O\ = /O
|
||||
# ____/`---'\____
|
||||
# . ' \\| |// `.
|
||||
# / \\||| : |||// \
|
||||
# / _||||| -:- |||||- \
|
||||
# | | \\\ - /// | |
|
||||
# | \_| ''\---/'' | |
|
||||
# \ .-\__ `-` ___/-. /
|
||||
# ___`. .' /--.--\ `. . __
|
||||
# ."" '< `.___\_<|>_/___.' >'"".
|
||||
# | | : `- \`.;`\ _ /`;.`/ - ` : | |
|
||||
# \ \ `-. \_ __\ /__ _/ .-` / /
|
||||
# ======`-.____`-.___\_____/___.-`____.-'======
|
||||
# `=---='
|
||||
#
|
||||
# .............................................
|
||||
# 佛祖保佑 永无BUG
|
||||
# 佛祖镇楼 BUG辟邪
|
||||
# --------------------------------代码区--------------------------------
|
||||
import requests
|
||||
import time
|
||||
import os
|
||||
import json
|
||||
import hashlib
|
||||
import math
|
||||
import random
|
||||
import logging
|
||||
import sys
|
||||
import string
|
||||
from base64 import b64encode
|
||||
import base64
|
||||
import uuid
|
||||
import re
|
||||
from datetime import datetime, timedelta
|
||||
from urllib.parse import urlparse, parse_qs,quote,unquote
|
||||
logging.basicConfig(level=logging.INFO, format='[%(levelname)s] ===> %(message)s')
|
||||
code = "搜搜小亏_api版"
|
||||
ver = "1.4"
|
||||
envname = "yuanshen_api"
|
||||
|
||||
debug = False #debug模式 开启即从脚本内部获取环境变量
|
||||
debugcookie = "" #debug模式cookie
|
||||
|
||||
is_bulletin = False #公告开关
|
||||
is_toulu = False #偷撸公告开关
|
||||
is_with_sleep = False #是否开启随机延时
|
||||
|
||||
|
||||
class env():
|
||||
"""
|
||||
env模块,获取cookie并转成列表,统计时间,提示脚本开始结束,检测一些配置,try except异常处理
|
||||
:param args: 传递给env的参数
|
||||
:param kwargs: 传递给env的关键字参数
|
||||
:return: Null
|
||||
|
||||
Powered by huaji
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.cookie = None
|
||||
self.env_ver = '1.5'
|
||||
self.split_chars = ['@', '&', '\n']
|
||||
self.identifiers = ['Powered By Huaji', 'QQ Group:901898186', 'yuanshen']
|
||||
def check_file(self):
|
||||
file_path = __file__
|
||||
try:
|
||||
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
content = file.read()
|
||||
|
||||
results = {}
|
||||
|
||||
# 批量检查每个标识符
|
||||
for identifier in self.identifiers:
|
||||
if identifier in content:
|
||||
results[identifier] = True
|
||||
else:
|
||||
results[identifier] = False
|
||||
logging.error(f"文件可能被恶意篡改,请勿修改文件内容")
|
||||
|
||||
all_identifiers_present = all(results.values())
|
||||
if not all_identifiers_present:
|
||||
logging.error(f"文件可能被恶意篡改,请勿修改文件内容")
|
||||
self.force_exit()
|
||||
|
||||
except Exception as e:
|
||||
print(f"读取文件时发生错误: {e}")
|
||||
self.force_exit()
|
||||
|
||||
def split_cookies(self):
|
||||
"""根据多个分隔符分割cookie"""
|
||||
for sep in self.split_chars:
|
||||
if sep in self.cookie:
|
||||
return self.cookie.split(sep)
|
||||
return [self.cookie]
|
||||
|
||||
def scmain(self):
|
||||
apiurl = 'http://' + self.cookies[0]
|
||||
r = requests.get(apiurl + '/getallwx').json()
|
||||
for i, cookie in enumerate(r, 1):
|
||||
print(f"--------开始第{i}个账号--------")
|
||||
main = yuanshen(cookie,apiurl)
|
||||
main.main()
|
||||
print(f"--------第{i}个账号执行完毕--------")
|
||||
|
||||
|
||||
|
||||
def force_exit(self,code=0):
|
||||
exit()
|
||||
print("Warning: 篡改你妈")
|
||||
os._exit(code) # 强制退出程序
|
||||
sys.exit(code) # 正常退出
|
||||
import ctypes
|
||||
while True:
|
||||
ctypes.string_at(114514)
|
||||
ctypes.string_at(1919810)
|
||||
ctypes.string_at(666666)
|
||||
print("Warning: 篡改你妈")
|
||||
|
||||
|
||||
def run(self):
|
||||
if not os.getenv(envname) and not debug:
|
||||
logging.warning(f"请先设置环境变量[{envname}]")
|
||||
self.force_exit()
|
||||
|
||||
self.cookie = os.getenv(envname, "")
|
||||
|
||||
if debug:
|
||||
self.cookie = debugcookie
|
||||
if is_bulletin:
|
||||
try:
|
||||
print(requests.get("https://gitee.com/HuaJiB/yuanshen34/raw/master/pubilc.txt").text, "\n\n\n")
|
||||
except:
|
||||
logging.error("网络异常,链接公告服务器失败(gitee),请检查网络")
|
||||
self.force_exit()
|
||||
if is_toulu:
|
||||
try:
|
||||
txt = '''
|
||||
此为滑稽的偷撸本本 如你不在滑稽的小群却意外通过某种渠道获得了该脚本
|
||||
请联系QQ3487934983 提供证据后 你将代替泄露人员获得该群位置
|
||||
=======================================================
|
||||
'''
|
||||
print(txt*5)
|
||||
except:
|
||||
self.force_exit()
|
||||
if is_with_sleep:
|
||||
random_time = random.randint(10,60)
|
||||
logging.info(f"随机延时[{random_time}]秒")
|
||||
time.sleep(random_time)
|
||||
|
||||
self.cookies = self.split_cookies()
|
||||
account_count = len(self.cookies)
|
||||
logging.info(f"一共获取到{account_count}个账号")
|
||||
print(f"=========🔔开始执行[{code}][{ver}]=========\n")
|
||||
|
||||
|
||||
start_time = time.time()
|
||||
if debug:
|
||||
self.scmain()
|
||||
else:
|
||||
try:
|
||||
self.scmain()
|
||||
except Exception as e:
|
||||
logging.error(f"脚本执行出错: {e}")
|
||||
end_time = time.time()
|
||||
|
||||
execution_time = end_time - start_time
|
||||
|
||||
print(f"\n============🔔脚本[{code}]执行结束============")
|
||||
print(f"本次脚本总运行时间: [{execution_time:.2f}] 秒")
|
||||
self.force_exit()
|
||||
|
||||
def main(self):
|
||||
self.check_file()
|
||||
self.run()
|
||||
|
||||
def random_str(self,charset="all", length=8, to_upper=False,to_lower=False):
|
||||
if charset == "all": #包含大小写字母和数字
|
||||
chars = string.ascii_letters + string.digits
|
||||
elif charset == "letters": #大小写字母
|
||||
chars = string.ascii_letters
|
||||
elif charset == "digits":
|
||||
chars = string.digits
|
||||
elif charset == "lowercase": #小写字母
|
||||
chars = string.ascii_lowercase
|
||||
elif charset == "uuid":
|
||||
return str(uuid.uuid4())
|
||||
elif charset == "uuid_str":
|
||||
return str(uuid.uuid4()).replace("-", "")
|
||||
elif charset != '' and charset is not None:
|
||||
chars = charset
|
||||
|
||||
|
||||
random_string = ''.join(random.choice(chars) for _ in range(length))
|
||||
|
||||
if to_upper:
|
||||
return random_string.upper()
|
||||
elif to_lower:
|
||||
return random_string.lower()
|
||||
else:
|
||||
return random_string
|
||||
|
||||
def aes_encrypt(self,data):
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Util.Padding import pad, unpad
|
||||
from binascii import hexlify, unhexlify
|
||||
key = self.key.encode('utf-8')
|
||||
iv = self.iv.encode('utf-8')
|
||||
cipher = AES.new(key, AES.MODE_CBC, iv)
|
||||
padded_plaintext = pad(data.encode('utf-8'), AES.block_size)
|
||||
ciphertext = cipher.encrypt(padded_plaintext)
|
||||
encrypted_base64 = b64encode(ciphertext).decode('utf-8')
|
||||
|
||||
return encrypted_base64
|
||||
|
||||
class yuanshen:
|
||||
def __init__(self,cookie,apiurl) -> None:
|
||||
self.apiurl = apiurl
|
||||
self.Wxid = cookie['Wxid']
|
||||
self.bz = cookie['wxname']
|
||||
logging.info(f'[{self.bz}]开始运行')
|
||||
|
||||
|
||||
def login(self):
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Linux; Android 14; 23113RKC6C Build/UKQ1.230804.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/126.0.6478.188 Mobile Safari/537.36 XWEB/1260183 MMWEBSDK/20240301 MMWEBID/98 MicroMessenger/8.0.48.2580(0x28003035) WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/wxpic,image/tpg,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
||||
# 'Accept-Encoding': 'gzip, deflate',
|
||||
'Upgrade-Insecure-Requests': '1',
|
||||
'X-Requested-With': 'com.tencent.mm',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
|
||||
}
|
||||
r = requests.get('http://auth.51zhejia.com/v1/user/auth', headers=headers,allow_redirects=False)
|
||||
login_url = (r.headers['Location'])
|
||||
print(login_url)
|
||||
data = {'Wxid':self.Wxid,'url':login_url}
|
||||
url = requests.post(self.apiurl+'/loginbyweb2',json=data).json()['url']
|
||||
code = url.split('code=')[1].split('&state')[0]
|
||||
url = f'http://auth.51zhejia.com/v1/user/back?jumpType=platform&ticket=&code={code}&state=search'
|
||||
r = requests.get(url, headers=headers,allow_redirects=False)
|
||||
url = r.headers['Location']
|
||||
print(code,url)
|
||||
j = parse_qs(urlparse(url).query)
|
||||
openid = json.loads(j.get('params')[0])['openId']
|
||||
print(openid)
|
||||
cookies = {
|
||||
'openId': openid,
|
||||
}
|
||||
headers = {
|
||||
'Host': 'search-api.lingxiaojiang.com',
|
||||
'Connection': 'keep-alive',
|
||||
'version': '4.0.0',
|
||||
'cache-control': 'no-cache',
|
||||
'ticket': '',
|
||||
'User-Agent': 'Mozilla/5.0 (Linux; Android 14; 23113RKC6C Build/UKQ1.230804.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/126.0.6478.188 Mobile Safari/537.36 XWEB/1260213 MMWEBSDK/20240301 MMWEBID/4020 MicroMessenger/8.0.48.2580(0x28003035) WeChat/arm64 Weixin Android Tablet NetType/WIFI Language/zh_CN ABI/arm64',
|
||||
'token': 'null',
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': '*/*',
|
||||
'Origin': 'http://1731024966.b27.yoga',
|
||||
'X-Requested-With': 'com.tencent.mm',
|
||||
'Referer': 'http://1731024966.b27.yoga/',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
|
||||
}
|
||||
|
||||
data = {
|
||||
'ticket': ''
|
||||
}
|
||||
r = requests.post('http://search-api.lingxiaojiang.com/v1/search/get-user-token', cookies=cookies, headers=headers, json=data).json()
|
||||
self.token = r['data']['token']
|
||||
logging.info(f'登录成功[{self.token}]')
|
||||
domain = str(int(time.time()*1000)) + '.j56.yoga'
|
||||
self.h = {
|
||||
"Host": "search-api.lingxiaojiang.com",
|
||||
"Connection": "keep-alive",
|
||||
"cache-control": "no-cache",
|
||||
"ticket": "",
|
||||
"User-Agent": "Mozilla/5.0 (Linux; Android 14; 23113RKC6C Build/UKQ1.230804.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/126.0.6478.188 Mobile Safari/537.36 XWEB/1260213 MMWEBSDK/20240301 MMWEBID/4020 MicroMessenger/8.0.48.2580(0x28003035) WeChat/arm64 Weixin Android Tablet NetType/WIFI Language/zh_CN ABI/arm64",
|
||||
"token": self.token,
|
||||
"version": "4.0.0",
|
||||
"Accept": "*/*",
|
||||
"Origin": f"http://{domain}",
|
||||
"X-Requested-With": "com.tencent.mm",
|
||||
"Referer": f"http://{domain}/",
|
||||
"Accept-Encoding": "gzip, deflate",
|
||||
"Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
|
||||
"Cookie": f"openId={openid}"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
def getread(self):
|
||||
r = requests.get('http://search-api.lingxiaojiang.com/v1/search/index', headers=self.h).json()
|
||||
if r["data"]["restLeftTime"] != 0:
|
||||
logging.info(f'[{self.bz}]距离下次阅读还有[{r["data"]["restLeftTime"]}]S')
|
||||
return False
|
||||
r = requests.get('http://search-api.lingxiaojiang.com/v1/search/get-task-info', headers=self.h).json()
|
||||
if r['code'] == 200:
|
||||
pageurl = unquote(r["data"]["pageUrl"])
|
||||
domain = urlparse(pageurl.split('&query=')[1]).netloc
|
||||
self.tid = pageurl.split('tid=')[1]
|
||||
logging.info(f'获取入口成功[{domain}][{self.tid}]')
|
||||
self.read_h = {
|
||||
'User-Agent': 'Mozilla/5.0 (Linux; Android 14; 23113RKC6C Build/UKQ1.230804.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/126.0.6478.188 Mobile Safari/537.36 XWEB/1260183 MMWEBSDK/20240301 MMWEBID/98 MicroMessenger/8.0.48.2580(0x28003035) WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64',
|
||||
# 'Accept-Encoding': 'gzip, deflate',
|
||||
'cache-control': 'no-cache',
|
||||
'token': 'null',
|
||||
'version': '3.0.0',
|
||||
'Origin': f'http://{domain}',
|
||||
'X-Requested-With': 'com.tencent.mm',
|
||||
'Referer': f'http://{domain}/',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
|
||||
}
|
||||
return True
|
||||
else:
|
||||
logging.info(f'获取入口失败[{r}]')
|
||||
return False
|
||||
def get_readtime(self,url):
|
||||
h = {
|
||||
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
||||
'accept-language': 'zh-CN,zh;q=0.9',
|
||||
'cache-control': 'no-cache',
|
||||
# 'cookie': 'RK=x93V1EQnnk; ptcz=70105284a73b47db6aa5f48a05337a8cd84e98de7bd26d75975059126646db21; pac_uid=0_ZkHRNfy6PMhrH; ua_id=SyF8Nc7qjhUZ6RH8AAAAAHO013VXlTF21GY7ajzLLgs=; _clck=19reoir|1|fpg|0; wxuin=27186344812218; eas_sid=x1Y7v2y759E6j1a811G6q158d0; qq_domain_video_guid_verify=08d525e64ffa56c3; _qimei_uuid42=18a1b130e12100363fb639c628b466967c0e1ac0aa; pgv_pvid=6915337851; _qimei_fingerprint=3c42962857167cc55475bb65b2331f0b; _qimei_h38=fded42463fb639c628b4669602000006018a1b; o_cookie=3487934983; _qimei_q32=ec50b72a0f5a646accacf4393f1271f2; _qimei_q36=9e46147a2ab8bee5904ab74e30001741890c; rewardsn=; wxtokenkey=777',
|
||||
'pragma': 'no-cache',
|
||||
'priority': 'u=0, i',
|
||||
'sec-ch-ua': '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"',
|
||||
'sec-fetch-dest': 'document',
|
||||
'sec-fetch-mode': 'navigate',
|
||||
'sec-fetch-site': 'none',
|
||||
'sec-fetch-user': '?1',
|
||||
'upgrade-insecure-requests': '1',
|
||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',
|
||||
}
|
||||
r = requests.get(url,headers=h).text
|
||||
match = re.search(r"var createTime = '(.+?)';", r)
|
||||
if match:
|
||||
date_string = (match.group(1))
|
||||
|
||||
date = datetime.strptime(date_string, "%Y-%m-%d %H:%M")
|
||||
half_year_ago = datetime.now() - timedelta(days=180)
|
||||
if date > half_year_ago:
|
||||
return False,date_string
|
||||
else:
|
||||
return True,date_string
|
||||
|
||||
def tuisong(self):
|
||||
url = f"{self.apiurl}/zdgjc"
|
||||
data = {"url":self.url}
|
||||
r = requests.post(url,json=data).json()
|
||||
logging.info(f"遇到检测文章:推送结果[{r}]")
|
||||
|
||||
def read(self):
|
||||
tid = 0
|
||||
while True:
|
||||
params = {
|
||||
'intranetIp': '10.1.10.1',
|
||||
'tid': self.tid,
|
||||
'taskDetailId':tid,
|
||||
}
|
||||
|
||||
r = requests.get('http://search-api.lingxiaojiang.com/v1/search/get-task-link', params=params, headers=self.read_h).json()
|
||||
if r["code"] != 200:
|
||||
logging.error(r)
|
||||
return
|
||||
|
||||
if r["data"]["taskFinish"]:
|
||||
logging.info(f'阅读任务完成')
|
||||
return
|
||||
self.url = r["data"]["taskDetail"]["link"]
|
||||
tid = r["data"]["taskDetail"]["taskDetailId"]
|
||||
now_num = r["data"]["searchSuccessTimes"]
|
||||
all_num = r["data"]["searchTimes"]
|
||||
va, date_string = self.get_readtime(self.url)
|
||||
logging.info(f'第[{now_num}/{all_num}]获取文章成功[{self.url}],文章时间[{date_string}]')
|
||||
if now_num in [0] or va:
|
||||
logging.info(f'遇到检测文章推送ing...')
|
||||
self.tuisong()
|
||||
time.sleep(random.uniform(18,25))
|
||||
else:
|
||||
time.sleep(random.uniform(8,15))
|
||||
|
||||
|
||||
|
||||
def userinfo(self):
|
||||
|
||||
r = requests.get('http://search-api.lingxiaojiang.com/v1/search/index', headers=self.h).json()
|
||||
|
||||
money = math.floor(r["data"]["userInfo"]["tokenBalance"] / 10000 * 10) / 10
|
||||
logging.info(f'当前余额[{money}]元')
|
||||
if money < 0.1:
|
||||
return
|
||||
data = {
|
||||
"amount": money
|
||||
}
|
||||
r = requests.post('http://search-api.lingxiaojiang.com/v1/token/withdraw', headers=self.h, json=data).json()
|
||||
if r["data"]["result"]:
|
||||
logging.info(f'提现[{money}]成功')
|
||||
else:
|
||||
logging.info(f'提现[{money}]失败')
|
||||
|
||||
|
||||
|
||||
def main(self):
|
||||
try:
|
||||
self.login()
|
||||
if self.getread():
|
||||
print('='*30)
|
||||
self.read()
|
||||
self.userinfo()
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
env().main()
|
||||
Loading…
Reference in New Issue
Block a user