修改下第10行的skey,21行的cookie,24行的formhash(也是小白弄这个,后面的删减实在是太杂,希望有大神出个简便点的)
[Python] 纯文本查看 复制代码 # -*- coding: utf8 -*-
#@Time:2020/9/17 2:42
#@Author:Yeeshao
#@File:IT论坛签到.py
#@Software:PyCharm
import requests
import re
from bs4 import BeautifulSoup
#
skey = '' #你的微信server酱skey
def push(content):
if skey != "":
url = "https://sc.ftqq.com/" + str(skey) + ".send?text=IT论坛签到信息&desp=" + str(content)
print("推送结果", requests.get(url).text)
def start():
url = 'https://www.itsk.com/plugin.php?id=dsu_paulsign:sign&operation=qiandao&infloat=1&inajax=1'
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3775.400 QQBrowser/10.6.4208.400',
'cookie': '你的cookie',
}
data = {
'formhash': '你的formhash', #去签到页面,按F12,点击签到,在network里的plug开头的data数据里有。
'qdxq': '7fd',
'qdmode': '1',
'todaysay': '奋斗',
'fastreply': '0',
}
html = requests.post(url=url, headers=headers, data=data).text
# print(html)
ex='<div class="c">(.*?)</div>' #查找特定文字内容
msg=re.findall(ex,html,re.S)[0]
print(msg)
# push((msg))
url2 = 'https://www.itsk.com/plugin.php?id=dsu_paulsign:sign'
data2 = {
'id': 'dsu_paulsign:sign',
}
html2 = requests.get(url=url2, headers=headers, params=data2).text
# print(html)
soup = BeautifulSoup(html2, 'lxml')
# # 以标**准的缩进格式**输出
# print(soup.prettify())
ex='<font color="#FF0000">(.*?)<h1 class="mt">' #查找特定文字内容
msg2=re.findall(ex,html2,re.S)[0]
# msg = re.sub('[<b></b></font></p>]', '', msg)
msg2 = msg2.replace('<b>', '')
msg2 = msg2.replace('<p>', '')
msg2 = msg2.replace('</b>', '')
msg2 = msg2.replace('</font>', '')
msg2 = msg2.replace('</p>', '')
msg2 = msg2.replace('<font color="#ff00cc">', '')
msg2 = msg2.replace('<font color=green>', '')
msg2 = msg2.replace('<font color=#FF0000>', '')
print(msg2)
msg=msg+'\n\n'+msg2
push((msg))
def main_handler(event, context):
return start()
if __name__ == '__main__':
start() |