|
|
@@ -79,6 +79,9 @@ def get_coinmarketcap_coin_price():
|
|
|
if max_circulating_supply:
|
|
|
result += f'max circulating supply: {max_circulating_supply[-1]}\n'
|
|
|
|
|
|
+ result += '\n'
|
|
|
+
|
|
|
+ print(f'已获取 {target} 数据')
|
|
|
time.sleep(2)
|
|
|
|
|
|
return result + '\n\n'
|
|
|
@@ -114,27 +117,59 @@ def get_vix_data():
|
|
|
print(resp.status_code)
|
|
|
return None
|
|
|
|
|
|
- data = resp.json()['data']['snapshot']['VIX.OTC']
|
|
|
+ try:
|
|
|
+ data = resp.json()['data']['snapshot']['VIX.OTC']
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ return None
|
|
|
|
|
|
result = f'{data[1]}:{data[2]}'
|
|
|
|
|
|
- return result
|
|
|
+ print('已获取 vix 指数')
|
|
|
+
|
|
|
+ return result + '\n\n'
|
|
|
|
|
|
|
|
|
def get_crypto_fear_and_greed_index():
|
|
|
url = 'https://coinmarketcap.com/charts/fear-and-greed-index/'
|
|
|
+ headers = {
|
|
|
+ "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
|
|
|
+ }
|
|
|
+ time.sleep(1)
|
|
|
+ resp = httpx.get(url=url, headers=headers)
|
|
|
+ if resp.status_code != 200:
|
|
|
+ print(resp.status_code)
|
|
|
+ return None
|
|
|
+ resp.encoding = 'utf-8'
|
|
|
+ page = resp.text
|
|
|
+
|
|
|
+ print('已获取 crypto 贪婪指数')
|
|
|
+
|
|
|
+ re_text = re.findall(
|
|
|
+ 'fearGreedIndexData":\{"currentIndex":\{"score":(.*?),"maxScore":100,"name":"(.*?)","updateTime":"(.*?)"}',
|
|
|
+ page)
|
|
|
+ if re_text:
|
|
|
+ text = f'crypto fear and greed index: {re_text[0][0]}\n{re_text[0][1]}\nupdate time: {re_text[0][2]}\n'
|
|
|
+ return text
|
|
|
+ else:
|
|
|
+ return None
|
|
|
|
|
|
|
|
|
def main():
|
|
|
+ text = ''
|
|
|
+
|
|
|
text = get_coinmarketcap_coin_price()
|
|
|
|
|
|
res = get_vix_data()
|
|
|
if res:
|
|
|
text += res
|
|
|
|
|
|
-
|
|
|
+ fear_and_greed = get_crypto_fear_and_greed_index()
|
|
|
+ if fear_and_greed:
|
|
|
+ text += fear_and_greed
|
|
|
|
|
|
if text:
|
|
|
+ print(text)
|
|
|
GotifyNotifier('Real-time coin price\n', text).send_message()
|
|
|
else:
|
|
|
print('No Data')
|