本帖最后由 Ne-21 于 2021-8-31 07:55 编辑
# -*- coding: utf8 -*-
import json
import hashlib
import requests
from bs4 import BeautifulSoup
def main_handler(event, context):
message = ""
username = '0'
passwd = '0'
kwparm = {'saltkey': 'NG6M727H',
'auth': 'c409BopLq9ONSqL7QlQ7ROPkV5hFLJctwFd6i6McaCimSmzb%2FSB0mQ4sJamka5pRHiZUwSz0t3fSa7gE79yQ7kxm21Y',
'dsu_amupper': 'DQo8c3R5bGU%2BDQoucHBlcndibSB7cGFkZGluZzo2cHggMTJweDtib3JkZXI6MXB4IHNvbGlkICNDRENEQ0Q7YmFja2dyb3VuZDojRjJGMkYyO2xpbmUtaGVpZ2h0OjEuOGVtO2NvbG9yOiMwMDMzMDA7d2lkdGg6MjAwcHg7b3ZlcmZsb3c6aGlkZGVufQ0KLnBwZXJ3Ym0gLnRpbWVze2NvbG9yOiNmZjk5MDA7fQ0KLnBwZXJ3Ym0gIGF7ZmxvYXQ6cmlnaHQ7Y29sb3I6I2ZmMzMwMDt0ZXh0LWRlY29yYXRpb246bm9uZX0NCjwvc3R5bGU%2BDQoNCjxkaXYgY2xhc3M9InBwZXJ3Ym0iIGlkPSJwcGVyd2JfbWVudSIgc3R5bGU9ImRpc3BsYXk6IG5vbmUiID4NCjxBIEhSRUY9InBsdWdpbi5waHA%2FaWQ9ZHN1X2FtdXBwZXI6cHBlcmxpc3QiIHRhcmdldD0iX2JsYW5rIj6y6b%2B0x6m1vcXF0NA8L0E%2BDQo8c3Ryb25nPsDbvMbHqbW9PHNwYW4gY2xhc3M9InRpbWVzIj4xNDA8L3NwYW4%2BtM48L3N0cm9uZz48YnI%2BDQoNCjxzdHJvbmc%2BwazQ%2BMeptb08c3BhbiBjbGFzcz0idGltZXMiPjE0MDwvc3Bhbj60zjwvc3Ryb25nPjxicj4NCg0KPHN0cm9uZz7Jz7TOx6m1vTogPHNwYW4gY2xhc3M9InRpbWVzIj4yMDIxLTA4LTI1IDA4OjU1OjA1PC9zcGFuPjwvc3Ryb25nPg0KPC9kaXY%2BDQo%3D'}
psw = hashlib.md5(passwd.encode('ascii'))
password = psw.hexdigest()
loginurl = 'http://bbs.06climate.com/member.php'
autourl = 'http://bbs.06climate.com/plugin.php'
homeurl = 'http://bbs.06climate.com/forum.php'
header = {}
params = {'mod': 'logging',
'action': 'login',
'loginsubmit': 'yes',
'infloat': 'yes',
'lssubmit': 'yes',
'inajax': 1}
foparam = {'mod': 'follow',
'do': 'follower'}
loginData = {'fastloginfield': 'username',
'username': username,
'password': password,
'quickforward': 'yes',
'handlekey': 'ls'}
cookie_value = 'bdshare_firstime=1476108193500; \
Dp7l_2132_saltkey=%(saltkey)s; \
Dp7l_2132_auth=%(auth)s; \
Dp7l_2132_dsu_amupper=%(dsu_amupper)s' % kwparm
cookie = {'Cookie': cookie_value}
s = requests.session()
getinfo = s.post(loginurl, params=params,
data=loginData, headers=header,
cookies=cookie)
if getinfo.text.find(username) > 0:
logout = True
message += '%s 成功登录!/n' % username
print('%s 成功登录!' % username)
homeinfo = s.get(homeurl, headers=header, cookies=cookie)
hc = BeautifulSoup(homeinfo.text, 'lxml')
rems = hc.find('a', {'id': 'myprompt'})
rr = rems.get_text()
ss = rr.replace(')', '(').split('(')
auparams = {'id': 'dsu_amupper',
'ppersubmit': 'true',
'formhash': '035c4186',
'infloat': 'yes',
'handlekey': 'dsu_amupper',
'inajax': 1,
'ajaxtarget': 'fwin_content_dsu_amupper'}
autoinfo = s.get(autourl, params=auparams, cookies=cookie)
if len(ss) > 1:
message += u'%s 有 %s 条信息!请查看!/n' % (username, ss[1])
elif len(ss) == 1:
message += u'无新消息!/n'
print(u'无新消息!')
else:
message += u'未知情况!/n'
if autoinfo.text.find(u'累计签到') > 0:
message += u'%s 签到成功!/n' % username
print(u'%s 签到成功!' % username)
elif autoinfo.text.find(u'无需再次签到!') > 0:
message += u'%s 已签到成功,无需再次签到!/n' % username
print(u'%s 已签到成功,无需再次签到!' % username)
else:
message += u'%s 签到出现问题!/n' % username
print(message)
Qmsg_send(message)
else:
logout = False
message += u'%s 登录失败!' % username
Qmsg_send(message)
print(message)
return("Hello World")
def Qmsg_send(msg):
QmsgKey = ''
if QmsgKey == '':
return
qmsg_url = 'https://qmsg.zendee.cn/send/' + str(QmsgKey)
data = {
'msg': msg,
}
requests.post(qmsg_url, data=data)