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.4 KiB
62 lines
2.4 KiB
from datetime import datetime
|
|
import json
|
|
import httpx
|
|
|
|
url = "https://api.chainalert.me/"
|
|
headers = {
|
|
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
|
|
}
|
|
text = ''
|
|
n = 0
|
|
with httpx.Client() as client:
|
|
for page in range(1, 5):
|
|
payload = {
|
|
"method": "listData",
|
|
"params": ['', "CRYPTO_RANK_AIRDROP", page, 0, 0, '']
|
|
}
|
|
for retry in range(10):
|
|
try:
|
|
response = client.post(url, headers=headers, data=payload, timeout=3)
|
|
except Exception as e:
|
|
print(str(e))
|
|
continue
|
|
if response.status_code != 200:
|
|
print(response.status_code)
|
|
continue
|
|
else:
|
|
data = response.json()
|
|
if not data:
|
|
client.close()
|
|
continue
|
|
|
|
try:
|
|
data_list = data['result']
|
|
airdrop_list = data_list[0]['data']
|
|
airdrop_list = json.loads(airdrop_list)
|
|
except Exception as e:
|
|
print(str(e))
|
|
continue
|
|
for airdrop in airdrop_list:
|
|
name = airdrop['name']
|
|
rank = airdrop['rank']
|
|
task = airdrop['item1']
|
|
update_date = airdrop['item2']['updateDate']
|
|
financing = airdrop['item4']
|
|
logoUrl = airdrop['logoUrl']
|
|
|
|
if task == '无任务':
|
|
continue
|
|
if task == 'No active tasks':
|
|
continue
|
|
|
|
task = '成本: {}, 耗时: {}, 任务类型: {}'.format(task.get('cost'), task.get('time'), task.get('task'))
|
|
|
|
text += '任务名称: {}\n排名: {}\n任务详细: {}\n更新时间: {}\n融资: {}\nlogo: {}\n'.format(name, rank, task, update_date, financing, logoUrl)
|
|
text += '=' * 50 + '\n'
|
|
n += 1
|
|
break
|
|
|
|
if text:
|
|
print(f'一共 {n} 条数据')
|
|
httpx.post('https://gotify.erhe.top/message?token=Aoe0VKt-kkZnm8d', headers={'Content-Type': 'application/json'}, json={'title': datetime.now().strftime('%Y-%m-%d %H:%M:%S'), 'message': text}) |