import requests
import re
import os
import time
import requests
data='{"offset":0,"limit":10}'
url="https://api.ctfhub.com/User_API/Event/getUpcoming"
print("【长野原机器人的比赛推送】")
response=requests.post(url,data)
for key in response.json()['data']['items']:
print("比赛名称:")
print(key['title'])
print("比赛时间:")
timestamp = key['start_time']
#转换成localtime
time_local = time.localtime(timestamp)
#转换成新的时间格式(2016-05-05 20:28:54)
dt = time.strftime("%Y-%m-%d %H:%M:%S",time_local)
print(dt)
print('~')
timestamp = key['end_time']
#转换成localtime
time_local = time.localtime(timestamp)
#转换成新的时间格式(2016-05-05 20:28:54)
dt = time.strftime("%Y-%m-%d %H:%M:%S",time_local)
print(dt)
print('***************************')
print("消息来源:ctfhub\n==================================")
a=os.popen("curl https://ctftime.org/event/list/upcoming") #使用a接收返回值
coun = 1
for key in a.readlines():
pattern0 = r'(.* teams will participate)'
pattern1 = r'<tr><td><a href="/event/.*">(.*)</td><td>Jeopardy</td><td>'
a2 = re.findall(pattern1,key)
if len(a2) >0:
print("比赛名称: ")
b1 = re.sub('<\/a><\/td><td>',' \n比赛时间:\n',a2[0])
b1 = re.sub('—','~',b1)
print(b1)
a1 = re.findall(pattern0,key)
if len(a1) >0:
b2 = re.sub('<\/td><td><\/td><td><b>','%\n参赛队伍数:\n',a1[0])
b2 = re.sub('<\/td><td>','ctftime的关注度:\n',b2)
b2 = re.sub('<\/b>','',b2)
print(b2)
print('**************************')
coun=coun+1
if coun == 5:
break
print("消息来源:ctftime")
print("\n*****************************")
print("【长野原机器人】提醒您:莫学憨thai老水群,多学原理多刷题,半夜靶场装萌新,早日上岸当菜鸡!")
暂无评论