148 lines
4.8 KiB
Python
148 lines
4.8 KiB
Python
import random
|
|
import time
|
|
|
|
from curl_cffi import requests
|
|
from pycparser.ply.ctokens import t_MINUS
|
|
from tonutils.utils import to_amount
|
|
|
|
|
|
def get_db_num(text, text1):
|
|
headers = {
|
|
'accept': '*/*',
|
|
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
|
# 'authorization': 'Bearer AFPJTKEBPOX3AIYAAAAKA2HWOTRNJP5MUCV5DMDCZAAOCPSAYEYS3CILNQVLF2HWKED6USY',
|
|
'cache-control': 'no-cache',
|
|
'content-type': 'application/json',
|
|
'dnt': '1',
|
|
'origin': 'https://tonviewer.com',
|
|
'pragma': 'no-cache',
|
|
'priority': 'u=1, i',
|
|
'referer': 'https://tonviewer.com/',
|
|
'sec-ch-ua': '"Not A(Brand";v="8", "Chromium";v="132", "Microsoft Edge";v="132"',
|
|
'sec-ch-ua-mobile': '?0',
|
|
'sec-ch-ua-platform': '"Windows"',
|
|
'sec-fetch-dest': 'empty',
|
|
'sec-fetch-mode': 'cors',
|
|
'sec-fetch-site': 'cross-site',
|
|
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 Edg/132.0.0.0',
|
|
}
|
|
|
|
params = {
|
|
'currencies': 'USD',
|
|
'supported_extensions': 'custom_payload',
|
|
}
|
|
|
|
for i in range(3):
|
|
try:
|
|
response = requests.get(
|
|
f'https://tonapi.io/v2/accounts/{text}/jettons/{text1}',
|
|
params=params,
|
|
headers=headers,
|
|
)
|
|
|
|
return to_amount(int(response.json()["balance"]))
|
|
except:
|
|
time.sleep(random.random())
|
|
|
|
return False
|
|
|
|
|
|
def get_ton_num(address):
|
|
headers = {
|
|
'accept': '*/*',
|
|
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
|
'authorization': 'Bearer AFPJTKEBPOX3AIYAAAAKA2HWOTRNJP5MUCV5DMDCZAAOCPSAYEYS3CILNQVLF2HWKED6USY',
|
|
'cache-control': 'no-cache',
|
|
'content-type': 'application/json',
|
|
'dnt': '1',
|
|
'origin': 'https://tonviewer.com',
|
|
'pragma': 'no-cache',
|
|
'priority': 'u=1, i',
|
|
'referer': 'https://tonviewer.com/',
|
|
'sec-ch-ua': '"Not A(Brand";v="8", "Chromium";v="132", "Microsoft Edge";v="132"',
|
|
'sec-ch-ua-mobile': '?0',
|
|
'sec-ch-ua-platform': '"Windows"',
|
|
'sec-fetch-dest': 'empty',
|
|
'sec-fetch-mode': 'cors',
|
|
'sec-fetch-site': 'cross-site',
|
|
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 Edg/132.0.0.0',
|
|
}
|
|
|
|
for i in range(3):
|
|
try:
|
|
response = requests.get(
|
|
f'https://tonapi.io/v2/accounts/{address}',
|
|
headers=headers,
|
|
)
|
|
|
|
return to_amount(int(response.json()["balance"]))
|
|
except:
|
|
|
|
time.sleep(random.random())
|
|
|
|
return False
|
|
|
|
|
|
def get_jettons(address):
|
|
headers = {
|
|
'accept': '*/*',
|
|
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
|
'authorization': 'Bearer AFPJTKEBPOX3AIYAAAAKA2HWOTRNJP5MUCV5DMDCZAAOCPSAYEYS3CILNQVLF2HWKED6USY',
|
|
'cache-control': 'no-cache',
|
|
'content-type': 'application/json',
|
|
'dnt': '1',
|
|
'origin': 'https://tonviewer.com',
|
|
'pragma': 'no-cache',
|
|
'priority': 'u=1, i',
|
|
'referer': 'https://tonviewer.com/',
|
|
'sec-ch-ua': '"Microsoft Edge";v="135", "Not-A.Brand";v="8", "Chromium";v="135"',
|
|
'sec-ch-ua-mobile': '?0',
|
|
'sec-ch-ua-platform': '"Windows"',
|
|
'sec-fetch-dest': 'empty',
|
|
'sec-fetch-mode': 'cors',
|
|
'sec-fetch-site': 'cross-site',
|
|
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0',
|
|
}
|
|
|
|
params = {
|
|
'currencies': 'USD',
|
|
'supported_extensions': 'custom_payload',
|
|
}
|
|
|
|
proxies = {
|
|
'http': 'socks5://192.168.50.220:25001',
|
|
'https': 'socks5://192.168.50.220:25001',
|
|
}
|
|
|
|
for i in range(3):
|
|
try:
|
|
|
|
response = requests.get(
|
|
f'https://tonapi.io/v2/accounts/{address}/jettons',
|
|
params=params,
|
|
headers=headers,
|
|
# proxies=proxies
|
|
)
|
|
|
|
jettons = []
|
|
for i in response.json()["balances"]:
|
|
if to_amount(int(i["balance"])) < 1:
|
|
continue
|
|
|
|
jetton_data = {}
|
|
jetton_data["name"] = i["jetton"]["name"]
|
|
jetton_data["balance"] = to_amount(int(i["balance"]))
|
|
jettons.append(jetton_data)
|
|
|
|
return jettons
|
|
except:
|
|
time.sleep(random.uniform(0.5, 9.5))
|
|
|
|
return False
|
|
|
|
|
|
if __name__ == '__main__':
|
|
print(get_jettons("UQCcVxU5yjD6JzrXy4PGo0D2I1zP3jKLzr9Fltsqqkg_bGP_"))
|
|
|
|
# print(get_ton_num(address="UQAGUYU7_KmA3Z2S0ycSTE1iRpi904k79EQME2xSgozbCErx"))
|