ggrg
This commit is contained in:
49
test111.py
49
test111.py
@@ -1,43 +1,10 @@
|
||||
import random
|
||||
import time
|
||||
|
||||
import requests
|
||||
from tonutils.utils import to_amount
|
||||
|
||||
|
||||
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
|
||||
from models.tg_phone_devices import TgPhoneDevices1, TgPhoneDevices
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(get_ton_num(address="EQD-8WpOhknZ6Wip9EN-jz5Tw-SJvYgu_x2FSDFlXH1kSo2O"))
|
||||
for i in TgPhoneDevices1.select():
|
||||
tg_info = TgPhoneDevices.get_or_none(
|
||||
phone=i.phone,
|
||||
)
|
||||
|
||||
i.port = tg_info.port
|
||||
i.save()
|
||||
|
||||
Reference in New Issue
Block a user