前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【更新】新赚吧每日打卡-Python源码

【更新】新赚吧每日打卡-Python源码

作者头像
偶尔敲代码
发布2023-04-28 10:26:13
3940
发布2023-04-28 10:26:13
举报
文章被收录于专栏:偶尔敲代码

不知不觉,上次的代码好像出问题了,参考了网上的思路,抽空更新了一下代码,如下:

代码语言:javascript
复制
import requests,time,re
from urllib import parse

cookies = '''【改成你的cookies,包含大括号】'''#浏览器上登录后按F12,切换到网络(Network)——标头
p_token= ''#push+token,需要推送填写,不需要不填

headers = {
        'Host': 'v1.xianbao.net',
        'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6 Mobile/15E148 Safari/604.1',
        'Origin': 'https://v1.xianbao.net',
        'cookie': cookies}

def 取中间文本(html, start_str, end):
    start = html.find(start_str)
    if start >= 0:
        start += len(start_str)
        end = html.find(end, start)
        if end >= 0:
            return html[start:end].strip()

def 取果果():
    url = "https://v1.xianbao.net/home.php?mod=spacecp&ac=credit&showcredit=1"
    response = requests.get(url=url, headers = headers, verify = False)
    #print(response.text)
    try:
        if response.text.find("果果") != -1:
            guo = 取中间文本(response.text, '''果果: </em>''', '''  &nbsp;''')
            dong = 取中间文本(response.text, '''果冻: </em>''', ''' </li>''')
            jf = 取中间文本(response.text, '''<em>积分: </em>''', ''' <span class=''')
            b = f"总积分:{jf},果果:{guo},果冻:{dong}"
        else:
            b = "积分获取失败"
    except Exception:
        b = "积分获取失败"
    return b

requests.packages.urllib3.disable_warnings()
url = 'https://v1.xianbao.net/'
response = requests.post(url = url, headers = headers, verify = False)
formhash = str(re.findall('name="formhash" value="(.*?)" />', response.text, re.S)).replace('[', '').replace('\'', '').replace(']', '')
#print(formhash)

url = 'https://v1.xianbao.net/app.php?p=sign&action=todaysign'
body = {'formhash': f'{formhash}'}
response = requests.post(url = url, headers = headers, data = "", verify = False)
sign = str(re.findall('<div id="messagetext" class="alert.*">\n<p>(.*?)<script type="text/javascript" reload="1">', response.text, re.S))
print(sign)
title = parse.quote_plus('xzk8打卡')
try:
    g = 取果果()
    print(g)
    content = parse.quote_plus(sign + "\n" + g + "\n微信公众号【偶尔敲代码】")
    requests.get(f'http://www.pushplus.plus/send?token={p_token}&title={title}&content={content}')
except Exception:
    print("打卡异常")

推送效果如下图:

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2023-02-14,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 偶尔敲代码 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档