|
@@ -5,6 +5,9 @@
|
|
|
|
|
|
|
|
import httpx
|
|
import httpx
|
|
|
import re
|
|
import re
|
|
|
|
|
+from bs4 import BeautifulSoup
|
|
|
|
|
+
|
|
|
|
|
+from utils.utils_send_gotify import *
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_coinmarketcap_coin_price(url, target):
|
|
def get_coinmarketcap_coin_price(url, target):
|
|
@@ -15,10 +18,10 @@ def get_coinmarketcap_coin_price(url, target):
|
|
|
|
|
|
|
|
if resp.status_code == 301:
|
|
if resp.status_code == 301:
|
|
|
print(resp.text)
|
|
print(resp.text)
|
|
|
- exit(0)
|
|
|
|
|
|
|
+ return None
|
|
|
elif resp.status_code != 200:
|
|
elif resp.status_code != 200:
|
|
|
print(resp.status_code)
|
|
print(resp.status_code)
|
|
|
- exit(0)
|
|
|
|
|
|
|
+ return None
|
|
|
|
|
|
|
|
resp.encoding = 'utf-8'
|
|
resp.encoding = 'utf-8'
|
|
|
page = resp.text
|
|
page = resp.text
|
|
@@ -54,6 +57,43 @@ def get_coinmarketcap_coin_price(url, target):
|
|
|
return result + '\n\n'
|
|
return result + '\n\n'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+def get_vix_data():
|
|
|
|
|
+ url = 'https://api-ddc-wscn.awtmt.com/market/real?'
|
|
|
|
|
+ headers = {
|
|
|
|
|
+ "Accept": "*/*",
|
|
|
|
|
+ "Accept-Encoding": "gzip, deflate, br, zstd",
|
|
|
|
|
+ "Accept-Language": "zh-CN,zh;q=0.9",
|
|
|
|
|
+ "Connection": "keep-alive",
|
|
|
|
|
+ "Host": "api-ddc-wscn.awtmt.com",
|
|
|
|
|
+ "If-None-Match": "AMJ+W5ydwGIw9oqT3fOBeQ==",
|
|
|
|
|
+ "Origin": "https://wallstreetcn.com",
|
|
|
|
|
+ "Referer": "https://wallstreetcn.com/",
|
|
|
|
|
+ "Sec-CH-UA": '"Chromium";v="130", "Brave";v="130", "Not?A_Brand";v="99"',
|
|
|
|
|
+ "Sec-CH-UA-Mobile": "?0",
|
|
|
|
|
+ "Sec-CH-UA-Platform": '"macOS"',
|
|
|
|
|
+ "Sec-Fetch-Dest": "empty",
|
|
|
|
|
+ "Sec-Fetch-Mode": "cors",
|
|
|
|
|
+ "Sec-Fetch-Site": "cross-site",
|
|
|
|
|
+ "Sec-GPC": "1",
|
|
|
|
|
+ "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"
|
|
|
|
|
+ }
|
|
|
|
|
+ params = {
|
|
|
|
|
+ "fields": "symbol,en_name,prod_name,last_px,px_change,px_change_rate,high_px,low_px,open_px,preclose_px,market_value,turnover_volume,turnover_ratio,turnover_value,dyn_pb_rate,amplitude,dyn_pe,trade_status,circulation_value,update_time,price_precision,week_52_high,week_52_low,static_pe,source",
|
|
|
|
|
+ "prod_code": "VIX.OTC"
|
|
|
|
|
+ }
|
|
|
|
|
+ resp = httpx.get(url=url, headers=headers, params=params)
|
|
|
|
|
+
|
|
|
|
|
+ if resp.status_code != 200:
|
|
|
|
|
+ print(resp.status_code)
|
|
|
|
|
+ return None
|
|
|
|
|
+
|
|
|
|
|
+ data = resp.json()['data']['snapshot']['VIX.OTC']
|
|
|
|
|
+
|
|
|
|
|
+ result = f'{data[1]}:{data[2]}'
|
|
|
|
|
+
|
|
|
|
|
+ return result
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
|
url_list = [
|
|
url_list = [
|
|
|
# ['BTC', 'https://www.coinmarketcap.com/currencies/bitcoin/'],
|
|
# ['BTC', 'https://www.coinmarketcap.com/currencies/bitcoin/'],
|
|
@@ -67,6 +107,17 @@ if __name__ == '__main__':
|
|
|
text = ''
|
|
text = ''
|
|
|
|
|
|
|
|
for data_list in url_list:
|
|
for data_list in url_list:
|
|
|
- text += get_coinmarketcap_coin_price(data_list[1], data_list[0])
|
|
|
|
|
|
|
+ res = get_coinmarketcap_coin_price(data_list[1], data_list[0])
|
|
|
|
|
+ if res:
|
|
|
|
|
+ text += res
|
|
|
|
|
+
|
|
|
|
|
+ res = get_vix_data()
|
|
|
|
|
+ if res:
|
|
|
|
|
+ text += res
|
|
|
|
|
|
|
|
print(text)
|
|
print(text)
|
|
|
|
|
+
|
|
|
|
|
+ if text:
|
|
|
|
|
+ GotifyNotifier('Real-time coin price\n', text).send_message()
|
|
|
|
|
+ else:
|
|
|
|
|
+ print('No Data')
|