代码拉取完成,页面将自动刷新
# -*- coding: utf8 -*-
"""
cron: 30 5,12,18 * * *
new Env('福利吧签到');
"""
import requests
import re
import os, sys
from sendNotify import send
def start(cookie, username):
try:
s = requests.session()
flb_url = get_addr()
headers = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Accept - Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9',
'cache-control': 'max-age=0',
'Host': flb_url,
'Upgrade-Insecure-Requests': '1',
'Cookie': cookie,
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 Edg/97.0.1072.62'}
# 访问Pc主页
user_info = s.get('https://' + flb_url + '/forum.php?mobile=no', headers=headers).text
user_name = re.search(r'title="访问我的空间">(.*?)</a>', user_info)
if user_name:
print("登录用户名为:" + user_name.group(1))
print("环境用户名为:" + username)
else:
print("未获取到用户名")
if user_name is None or (user_name.group(1) != username):
raise Exception("【福利吧】cookie失效???????")
# 获取签到链接,并签到
qiandao_url = re.search(r'}function fx_checkin(.*?);', user_info).group(1)
qiandao_url = qiandao_url[47:-2]
print(qiandao_url)
# 签到
s.get('https://' + flb_url + '/' + qiandao_url, headers=headers).text
# 获取积分
user_info = s.get('https://' + flb_url + '/forum.php?mobile=no', headers=headers).text
current_money = re.search(r'<a.*? id="extcreditmenu".*?>(.*?)</a>', user_info).group(1)
sing_day = re.search(r'<div class="tip_c">(.*?)</div>', user_info).group(1)
log_info = "{}当前{}".format(sing_day, current_money)
print(log_info)
send("签到结果", log_info)
except Exception as e:
print("签到失败,失败原因:"+str(e))
send("签到结果", str(e))
def get_addr():
pub_page = "https://fuliba-1251744788.file.myqcloud.com"
ret = requests.get(pub_page)
ret.encoding = "utf-8"
bbs_addr = re.findall(r'<a href=.*?><i>https://(.*?)</i></a>', ret.text)[1]
return bbs_addr
if __name__ == '__main__':
# cookie = "此处填入COOKIE"
# username = "此处填入用户名"
cookie = os.getenv("FUBA")
user_name = os.getenv("FUBAUN")
start(cookie, user_name)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。