You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.1 KiB
62 lines
2.1 KiB
# -*- coding: utf-8 -*-
|
|
'''
|
|
获取麦子钱包实时 gas
|
|
'''
|
|
import os
|
|
import sys
|
|
|
|
sys.path.append(os.path.join(os.path.abspath(__file__).split('auto')[0] + 'auto'))
|
|
|
|
|
|
from utils.utils_send_gotify import *
|
|
|
|
url = "https://a5.maiziqianbao.net/api/v1/chains/EVM/1/gas_price"
|
|
|
|
headers = {
|
|
"Host": "a5.maiziqianbao.net",
|
|
"Connection": "keep-alive",
|
|
"x-req-token": "MDbO4FsaSUPdjCdvTUs2zY4V3rnvvYatvYyjz7SfY+aCJ8r+RFm06X2dGR8eEDK7Gc5g1TLEQySEhGerRXbDT/NS+e5QAWRU68yD8m4y/aKK+TBkIv90VwvxmvYId2BVoDPDHQCGG4o3EqRWkS93eV0twYQ7w7qvNUj2e3tpDcUZYuplPyLozgYVTegFPnDk",
|
|
"Accept": "*/*",
|
|
"x-app-type": "iOS-5",
|
|
"x-app-ver": "1.0.1",
|
|
"x-app-udid": "419815AD-3015-4B5A-92CA-3BCBED24ACEC",
|
|
"x-app-locale": "en",
|
|
"Accept-Language": "zh-Hans-CN;q=1.0, en-CN;q=0.9",
|
|
"Accept-Encoding": "br;q=1.0, gzip;q=0.9, deflate;q=0.8",
|
|
"User-Agent": "MathGas/1.0.1 (MathWallet.MathGas; build:3; macOS 13.5.0) Alamofire/5.4.4"
|
|
}
|
|
|
|
response = httpx.get(url, headers=headers)
|
|
if response.status_code != 200:
|
|
print("Error:", response.status_code)
|
|
exit(0)
|
|
|
|
if not response.json():
|
|
print("Error: No response")
|
|
exit(0)
|
|
|
|
remove_last_n_chars = lambda n, n_chars=9: int(str(n)[:-n_chars]) if len(str(n)) > n_chars else n
|
|
|
|
try:
|
|
data = response.json()['data']
|
|
|
|
fastest = remove_last_n_chars(data['fastest']['price'])
|
|
fast = remove_last_n_chars(data['fast']['price'])
|
|
standard = remove_last_n_chars(data['standard']['price'])
|
|
low = remove_last_n_chars(data['low']['price'])
|
|
base = remove_last_n_chars(data['base']['price'])
|
|
result = f'fastest: {fastest}\nfast: {fast}\nstandard: {standard}\nlow: {low}\nbase: {base}'
|
|
|
|
print(result)
|
|
|
|
if int(fastest) > 30 or int(fast) > 30 or int(standard) > 30 or int(low) > 30 or int(base) > 30:
|
|
# 推送到 message
|
|
GotifyNotifier('gas 费大于 30', result, 'coin').send_message()
|
|
elif int(fastest) < 5 or int(fast) < 5 or int(standard) < 5 or int(low) < 5 or int(base) < 5:
|
|
# 推送到 message
|
|
GotifyNotifier('gas 费小于 5', result, 'coin').send_message()
|
|
|
|
|
|
except Exception as e:
|
|
print(e)
|
|
exit(0)
|
|
|