近日,推荐朋友了一个社区,觉得不错,我想着干脆写个脚本,把它放到服务器上,实时转发其他站点的快讯这样的一个小程序,这样就不用每天登录的应用程序,还要手动去写文章发布了。
一、编写获取快讯文章列表的类
class Block_API():
def __init__(self):
self.headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36',
}
def alerts(self):
# 获取快讯数据
url = 'https://block.cc/api/v1/alerts/list'
try:
return requests.get(url=url, params={'page':0,'size':10}, headers=self.headers).json()['data']['list']
except:
return []
快讯文章的来源是block.cc,返回的数据类型是JSON数据类型
二、编写登录社区,发布文章的类
class XBei():
def __init__(self):
self.headers = {
'accept': 'application/json, text/plain, */*',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'zh-CN,zh;q=0.9',
'authorization':'填写你社区登录后的headers信息',
'if-none-match':'填写你社区登录后的headers信息',
'origin': 'https://t.northx.cn',
'referer': 'https://t.northx.cn/',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36'
}
def Create(self, content):
# 发表文章:
url = 'https://api.northx.cn/statuses/create'
code = requests.post(url=url, data={"content":content}, headers=self.headers).status_code
if code==200:
print(u'发帖成功:%s...' % (content[:50]))
else:
print(u'发帖失败:错误代码(%s)' % (code))
注意:在报头信息里面的授权,如果无的匹配,需要填写你登录社区后的信息,关于头信息的获取这里不作细谈,自行度娘
三、开始运行
def start():
Alerts = Block_API().alerts()
try:
# ID列表是保存已经发布过的文章id,刷新时避免重复发布相同文章
ID = pickle.load(open('tmp.pickle', 'rb'))
except:
ID = []
id = []
if Alerts:
for a in Alerts:
if a['_id'] not in ID:
content = a['content'] + '\n来源:' + a['from']
XBei().Create(content=content)
id.append(a['_id'])
pickle.dump(id, open('tmp.pickle', 'wb'))
else:
print(u'获取文章列表错误!')
if __name__ == '__main__':
while True:
start()
time.sleep(60) # 设定每60s的时间刷新一次
好了,至此文章结束以下是应用程序的转发效果,这样只要有文章更新就直接转发到app上:
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
555
(select 198766*667891 from DUAL)
(select 198766*667891)
@@mEzBv
555����%2527%2522\'\"
555'"
555
555'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
5558ETJB2gN')) OR 656=(SELECT 656 FROM PG_SLEEP(15))--
555RJ1TDMvK') OR 915=(SELECT 915 FROM PG_SLEEP(15))--
5558xiXWXqk' OR 400=(SELECT 400 FROM PG_SLEEP(15))--
555-1)) OR 493=(SELECT 493 FROM PG_SLEEP(15))--
555-1) OR 726=(SELECT 726 FROM PG_SLEEP(15))--
555-1 OR 102=(SELECT 102 FROM PG_SLEEP(15))--
5551rwoXzAD'
555-1 waitfor delay '0:0:15' --
555-1)
555-1
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
5550"XOR(555*if(now()=sysdate(),sleep(15),0))XOR"Z
5550'XOR(555*if(now()=sysdate(),sleep(15),0))XOR'Z
555*if(now()=sysdate(),sleep(15),0)
-1" OR 5*5=25 or "RHorP48P"="
-1' OR 5*5=25 or 'RcpVG3iL'='
-1" OR 5*5=25 --
-1' OR 5*5=25 --
-1 OR 5*5=25
-1 OR 5*5=25 --
555
555
555