|
|
@@ -155,6 +155,51 @@ def get_crypto_fear_and_greed_index():
|
|
|
return None
|
|
|
|
|
|
|
|
|
+def get_gas_value():
|
|
|
+ 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)
|
|
|
+ return None
|
|
|
+
|
|
|
+ if not response.json():
|
|
|
+ print("Not Find GAS Data. Error: No response")
|
|
|
+ return None
|
|
|
+
|
|
|
+ remove_last_n_chars = lambda n, n_chars=9: int(str(n)[:-n_chars]) if len(str(n)) > n_chars else n
|
|
|
+
|
|
|
+ result = '\nGAS:\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}'
|
|
|
+ return result
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ return None
|
|
|
+
|
|
|
+
|
|
|
def main():
|
|
|
text = ''
|
|
|
|
|
|
@@ -168,6 +213,10 @@ def main():
|
|
|
if fear_and_greed:
|
|
|
text += fear_and_greed
|
|
|
|
|
|
+ gas = get_gas_value()
|
|
|
+ if gas:
|
|
|
+ text += gas
|
|
|
+
|
|
|
if text:
|
|
|
print(text)
|
|
|
GotifyNotifier('Real-time coin price\n', text).send_message()
|