├── README.md
├── chrome-win64.7z
├── laowang.py
├── lvyuan.py
├── old
└── sijishe.py
├── pcr532.py
├── sendNotify.py
├── sijishe.py
└── sijishe_login.py
/README.md:
--------------------------------------------------------------------------------
1 | # AutoCheckIn
2 |
3 | ### 自用签到集合
4 |
5 | ####本项目中的脚本推荐在青龙中使用,也兼容在阿里云函数运行
6 |
7 | 1、pcr532App签到 第一天1积分,第二天2积分,依次增加,上限是7 \
8 | 可兑换积分商城里的所有东西 \
9 | 有需要的 可自行到 https://www.rfidfans.com/ 下载APP注册
10 |
11 | 2、sijishe签到 LSP都懂,脚本可自动从sijishe.me获取最新地址进行账号登录、签到 \
12 | 嗯,资源很贵,车票很重要
13 |
14 | 3、增加老王部落签到,可获取签到积分奖励,每7天一轮每日奖励
15 |
16 |
17 |
18 | sijishe由20240717开始只支持docker版青龙,其它方式请自行研究使用
19 |
20 | sijishe网站做了加密,由于不懂js,索性直接换selenium方式来搞定,关于青龙面板
21 | 安装selenium和对应的chromiumdriver安装方式,看下边的说明吧
22 |
23 | 青龙面板中可以直接安装 selenium 依赖
24 |
25 | 安装chromium, 先进入到docker青龙的控制台中
26 |
27 | ```
28 | docker exec -it qinglong bash
29 | ```
30 |
31 | 按照下边步骤进行安装
32 | 1、切换国内镜像源
33 |
34 | ```
35 | sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
36 | ```
37 |
38 | 2、安装chromium以及chromiumdriver
39 |
40 | ```
41 | apk add chromium
42 | apk add chromium-chromedriver
43 | ```
44 |
45 | 3、如果遇到报错,查看报错内容是不是selenium和chromedriver版本不匹配造成的
46 |
47 | ```
48 | # 降级安装对应的版本
49 | pip install urllib3==2.1.0
50 | pip install selenium==4.8.0
51 | ```
52 |
53 | 4、使用 python代码 测试是否安装成功,以上安装没问题,可以不用测试
54 |
55 | ```
56 | # -*-coding: utf-8 -*-
57 | from selenium import webdriver
58 | chrome_options = webdriver.ChromeOptions()
59 | chrome_options.add_argument('--headless')
60 | chrome_options.add_argument('--no-sandbox')
61 | chrome_options.add_argument('--disable-gpu')
62 | chrome_options.add_argument('--disable-dev-shm-usage')
63 | driver = webdriver.Chrome(options=chrome_options)
64 | driver.get('https://www.baidu.com')
65 | print(driver.title)
66 | ```
67 |
68 | sijishe_login.py 用到的组件 https://jzjbyq.lanzouo.com/ilFmi24pabha
--------------------------------------------------------------------------------
/chrome-win64.7z:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jzjbyq/AutoCheckIn/e5dfe38934d3503947238e0a4ff194c176087a8a/chrome-win64.7z
--------------------------------------------------------------------------------
/laowang.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf8 -*-
2 |
3 | """
4 | cron: 0 8 * * *
5 | new Env('老王资源部落签到');
6 | 环境变量名称:LAOWANG_CK
7 | cookie抓包 wordpress_sec_xxxxxxxxxx 即可
8 | 多个账号使用@或者换行间隔
9 | 青龙Python依赖, requests, lxml
10 | [task_local]
11 | #老王资源部落签到
12 | 0 8 * * * https://raw.githubusercontent.com/jzjbyq/AutoCheckIn/main/laowangziyuan.py, tag=老王资源部落签到, enabled=true
13 | [rewrite_local]
14 | https://www.laowang2222.com url script-request-header https://raw.githubusercontent.com/jzjbyq/AutoCheckIn/main/laowangziyuan.py
15 | """
16 |
17 | import re
18 | import os
19 | import requests
20 | import urllib3
21 | import time
22 | from sendNotify import send
23 | from lxml import etree
24 |
25 | urllib3.disable_warnings()
26 | send_content = ''
27 |
28 | #1
29 | def start(ck):
30 | global send_content
31 | try:
32 | payload = re.split('@|\n', ck)
33 | print('发现', len(payload), '个账号信息\n')
34 | send_content += f'发现 {len(payload)} 个账号信息\n'
35 | except Exception as e:
36 | print(e)
37 | print('环境变量格式错误, 程序退出')
38 | exit(0)
39 | for i in payload:
40 | name = re.findall('.*\=(.*?)[\%\|]', i)[0]
41 | # 过期时间,盲猜,不一定准
42 | end_time = re.findall('7C([0-9]{10})', i)[0]
43 | timeArray = time.localtime(int(end_time))
44 | end_time = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
45 | headers = {
46 | 'authority': 'www.laowang2222.com',
47 | 'accept': 'application/json, text/javascript, */*; q=0.01',
48 | 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
49 | 'cache-control': 'no-cache',
50 | 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
51 | 'cookie': i,
52 | 'origin': 'https://www.laowang2222.com',
53 | 'pragma': 'no-cache',
54 | 'referer': 'https://www.laowang2222.com/',
55 | 'sec-ch-ua': '"Not?A_Brand";v="8", "Chromium";v="108", "Microsoft Edge";v="108"',
56 | 'sec-ch-ua-mobile': '?0',
57 | 'sec-ch-ua-platform': '"Windows"',
58 | 'sec-fetch-dest': 'empty',
59 | 'sec-fetch-mode': 'cors',
60 | 'sec-fetch-site': 'same-origin',
61 | 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.42',
62 | 'x-requested-with': 'XMLHttpRequest',
63 | }
64 | # 开始签到
65 | data = {
66 | 'action': 'user_checkin',
67 | }
68 | # {'msg': '连续4天签到成功! 积分+20 经验值+5', 'data': {'integral': 5, 'points': 20, 'time': '2022-11-18 15:51:55'}, 'continuous_day': 4, 'details_link': '', 'error': False}
69 | res = requests.post('https://www.laowang2222.com/wp-admin/admin-ajax.php', headers=headers,
70 | data=data).json()
71 | if res == 0:
72 | print(name, '的Cookie已过期')
73 | send_content += f'{name} 的Cookie已过期\n'
74 | continue
75 | msg = res['msg']
76 |
77 | # 获取签到天数
78 | params = {
79 | 'action': 'checkin_details_modal',
80 | }
81 | try:
82 | res = requests.get('https://www.laowang2222.com/wp-admin/admin-ajax.php', params=params, headers=headers)
83 | qday = re.findall(r'(.*)', res.text)[0]
84 | # print(qday)
85 | except:
86 | qday = '未知'
87 |
88 | # 获取当前积分数
89 | try:
90 | res = requests.get('https://www.laowang2222.com/user/balance', headers=headers)
91 | rhtml = etree.HTML(res.text)
92 | integral = rhtml.xpath('//*[@id="user-tab-balance"]/div[1]/div[1]/div/div/div[2]/div[1]/span/text()')[0]
93 | except Exception as e:
94 | print(e)
95 |
96 | xm = "账户【" + name + "】"
97 | xm = xm.center(24, '=')
98 | print(
99 | f'{xm}\n签到状态: {msg} \n当前积分: {integral}\n累计签到:{qday}天\nCK过期时间: {end_time}\n\n')
100 | send_content += f'{xm}\n签到状态: {msg} \n当前积分: {integral}\n累计签到:{qday}天\nCK过期时间:{end_time}\n\n'
101 |
102 | send('老王资源部落签到', send_content)
103 |
104 |
105 | # 阿里云函数入口s
106 | def handler(event, context):
107 | try:
108 | _postdata = os.environ['LAOWANG_CK']
109 | except Exception:
110 | print('未设置环境变量 LAOWANG_CK')
111 | exit(0)
112 | start(_postdata)
113 | exit(0)
114 |
115 |
116 | if __name__ == '__main__':
117 | handler('', '')
118 |
--------------------------------------------------------------------------------
/lvyuan.py:
--------------------------------------------------------------------------------
1 | """
2 | 抓包地址:vip.luyuan.cn/huiyuan/userbike/list
3 | 多个账号使用@或者换行间隔
4 | 青龙Python依赖, requests, urllib3, os, re, json
5 | [task_local]
6 | #绿源电动车签到
7 | 0 8,22 * * * https://raw.githubusercontent.com/jzjbyq/AutoCheckIn/main/lvyuan.py, tag=绿源电动车签到, enabled=true
8 | """
9 |
10 | import json
11 | import os
12 | import re
13 |
14 | import requests
15 | import urllib3
16 |
17 | from sendNotify import send
18 |
19 | urllib3.disable_warnings()
20 | send_content = ''
21 |
22 | def start(ck):
23 | global send_content
24 | try:
25 | payload = re.split('@|\n', ck)
26 | print('发现', len(payload), '个账号信息\n')
27 | send_content += f'发现 {len(payload)} 个账号信息\n\n'
28 | except Exception as e:
29 | print(e)
30 | print('环境变量格式错误, 程序退出')
31 | exit(0)
32 |
33 | for i in payload:
34 | authorization = i
35 | # api_sign = re.split(',', i)[1]
36 | check_in(authorization)
37 |
38 | send('绿源电动车签到', send_content)
39 |
40 |
41 | def check_in(authorization):
42 | global send_content
43 | headers = {
44 | 'Host': 'vip.luyuan.cn',
45 | 'Connection': 'keep-alive',
46 | 'authorization': authorization,
47 | 'charset': 'utf-8',
48 | # 'api-key': api_key,
49 | # 'api-sign': api_sign,
50 | 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; HD1900 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/111.0.5563.116 Mobile Safari/537.36 XWEB/5235 MMWEBSDK/20230303 MMWEBID/3666 MicroMessenger/8.0.34.2340(0x28002237) WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64 MiniProgramEnv/android',
51 | 'content-type': 'application/json',
52 | 'Accept-Encoding': 'gzip,compress,br,deflate',
53 | 'Referer': 'https://servicewechat.com/wx7a47c4837513ee24/143/page-frame.html',
54 | }
55 | postdata = {}
56 | # 获取昵称
57 | name = ''
58 | try:
59 | res = requests.get('https://vip.luyuan.cn/huiyuan/user/userprofile/fetch', headers=headers, verify=False)
60 | resjson = json.loads(res.text)
61 | if resjson['ok'] == True:
62 | name = resjson['data']['nickname']
63 | except Exception as e:
64 | print('get name', e)
65 |
66 | # 签到
67 | try:
68 | res = requests.post('https://vip.luyuan.cn/huiyuan/usertask/user/sign/in', headers=headers, data=postdata,
69 | verify=False)
70 | resjson = json.loads(res.text)
71 | if resjson['ok'] == True:
72 | print(f'{name} 签到成功')
73 | send_content += f'{name} 签到成功\n'
74 | elif resjson['ok'] == False:
75 | print(f'{name} 已经签到')
76 | send_content += f'{name} 已经签到\n'
77 | except Exception as e:
78 | print(e)
79 |
80 | # 获取总积分
81 | try:
82 | res = requests.get('https://vip.luyuan.cn/huiyuan/user/fetch', headers=headers, verify=False)
83 | resjson = json.loads(res.text)
84 | if resjson['ok'] == True:
85 | totalpoints = resjson['data']['totalpoints']
86 | print(f'当前总积分: {totalpoints}')
87 | send_content += f'当前总积分: {totalpoints}\n\n'
88 | except Exception as e:
89 | print('get totalpoints', e)
90 |
91 |
92 | # 阿里云函数入口
93 | def handler(event, context):
94 | try:
95 | _postdata = os.environ['LVYUAN_CK']
96 | except Exception:
97 | print('未设置环境变量 LVYUAN_CK')
98 | exit(0)
99 | start(_postdata)
100 | exit(0)
101 |
102 |
103 | if __name__ == '__main__':
104 | handler('', '')
105 |
--------------------------------------------------------------------------------
/old/sijishe.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf8 -*-
2 |
3 | """
4 | cron: 0 8 * * *
5 | new Env('司机社签到');
6 | 环境变量名称:XSIJISHE
7 | 直接使用账号密码登录,格式: 账号&密码
8 | 多个账号使用@或换行间隔
9 | 青龙Python依赖, requests, lxml
10 | [task_local]
11 | #司机社签到
12 | 0 8 * * * https://raw.githubusercontent.com/jzjbyq/AutoCheckIn/main/sijishe.py, tag=司机社签到, enabled=true
13 | [rewrite_local]
14 | https://sijishea.com url script-request-header https://raw.githubusercontent.com/jzjbyq/AutoCheckIn/main/sijishe.py
15 | """
16 |
17 | import os
18 | from lxml import etree
19 | import time
20 | from sendNotify import send
21 | import urllib3
22 | import re
23 | import hashlib
24 | import requests
25 | import random
26 |
27 | urllib3.disable_warnings()
28 |
29 | # 初始化签到状态值
30 | checkIn_content = '今日已签到', '签到成功', 'Cookie失效'
31 | checkIn_status = 2
32 | send_content = ''
33 | cookies = {}
34 |
35 | # 签到积分信息页面
36 | sign_url = '/k_misign-sign.html'
37 |
38 | formhash = ''
39 | main_url = ''
40 | headers = {}
41 |
42 |
43 | def string_to_md5(key):
44 | md5 = hashlib.md5()
45 | md5.update(key.encode("utf-8"))
46 | return md5.hexdigest()
47 |
48 |
49 | def getrandom(code_len):
50 | all_char = 'qazwsxedcrfvtgbyhnujmikolpQAZWSXEDCRFVTGBYHNUJIKOLP'
51 | index = len(all_char) - 1
52 | code = ''
53 | for _ in range(code_len):
54 | num = random.randint(0, index)
55 | code += all_char[num]
56 | return code
57 |
58 |
59 | # 从发布页获取网站地址
60 | def get_new_url():
61 | global main_url
62 | url = 'https://sijishe.me/'
63 | ot_num = 1
64 | ot_max_num = 10
65 | while ot_num < ot_max_num:
66 | try:
67 | res = requests.get(url)
68 | rhtml = etree.HTML(res.content.decode('utf-8'))
69 |
70 | urls = checkstatus(rhtml)
71 | if urls == '0':
72 | print('所有站点都访问失败, 请检查自身网络')
73 | exit(0)
74 | main_url = urls
75 | # print(main_url)
76 | return 1
77 | except Exception as e:
78 | print('错误内容', e)
79 | print(f'发布页地址获取失败,正在进行第{ot_num}/{ot_max_num}次重试')
80 | time.sleep(10)
81 | ot_num += 1
82 | exit(0)
83 |
84 | # 发布页中的最新站点按顺序自动切换
85 | def checkstatus(r_xpath):
86 | r_xpath_num = r_xpath.xpath(f'//*[@id="main"]/div/div[2]/div/div/a')
87 | for i in range(1, len(r_xpath_num)):
88 | url_name = r_xpath.xpath(f'//*[@id="main"]/div/div[2]/div/div/a[{str(i)}]/text()')[0]
89 | if '最新地址' in url_name:
90 | cs_url = r_xpath.xpath(f'//*[@id="main"]/div/div[2]/div/div/a[{str(i)}]/@href')[0]
91 | try:
92 | print('检测网址', cs_url)
93 | cs_res = requests.get(cs_url)
94 | if cs_res.status_code == 200:
95 | print('网址', cs_url, '有效, 开始签到')
96 | return cs_url
97 | except:
98 | print('网址', cs_url, '失败, 切换下一个地址')
99 | return '0'
100 |
101 | # 初始化cookie和页面formhash信息
102 | def get_cookie_formhash():
103 | global formhash
104 | formhash = ''
105 | response = requests.get(main_url + '/member.php?mod=logging&action=login&frommessage')
106 | # response.cookies 返回为cookiejar,需转成json方便使用
107 | cookiejar_to_json(response.cookies)
108 | # print(cookies)
109 | formhash = re.findall(r'', response.text)[0]
110 | # print(formhash[0])
111 |
112 |
113 | # cookiejar转为json
114 | def cookiejar_to_json(Rcookie):
115 | global cookies
116 | for item in Rcookie:
117 | cookies[item.name] = item.value
118 |
119 |
120 | def login(username, password):
121 | data = {
122 | 'formhash': formhash,
123 | 'referer': main_url + '/home.php?mod=space&do=pm&filter=newpm',
124 | 'username': username,
125 | 'password': password,
126 | 'questionid': '0',
127 | 'answer': '',
128 | }
129 |
130 | login_url = main_url + '/member.php?mod=logging&action=login&loginsubmit=yes&frommessage&loginhash=Lt' + getrandom(
131 | 3) + '&inajax=1'
132 | try:
133 | response = requests.post(login_url, cookies=cookies, headers=headers, data=data)
134 | cookiejar_to_json(response.cookies)
135 | response.text.index('欢迎您回来')
136 | # print('登录成功')
137 | # print(cookies)
138 | return 1
139 | except:
140 | print(f'账号{username}登录失败,请检查账号密码, 可能是验证码问题,等待更新...')
141 | return 0
142 |
143 |
144 | def start(postdata):
145 | # 账号数据按格式分割
146 | global send_content
147 | try:
148 | payload = re.split('@|\n', postdata)
149 | print('发现', len(payload), '个账号信息\n')
150 | send_content += f'发现 {len(payload)} 个账号信息\n'
151 | # info = '发现 ' + str(len(payload)) + ' 个账号信息\n\n'
152 | except:
153 | print('环境变量格式错误, 程序退出')
154 | print(e)
155 | exit(0)
156 | global checkIn_status
157 |
158 | for i in payload:
159 | try:
160 | u = i.split('&')
161 | # 读取账号到变量,密码为md5编码后的字符串
162 | name = u[0]
163 | pwd = string_to_md5(u[1])
164 | except:
165 | print('账号参数格式错误')
166 | break
167 |
168 | # 刷新cookie和formhash值,用作登录
169 | get_cookie_formhash()
170 | if not login(name, pwd):
171 | send_content += f'账号{name}登录失败,请检查账号密码\n\n'
172 | continue
173 | headers = {
174 | 'referer': main_url + '/',
175 | 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36 Edg/101.0.1210.39'
176 | }
177 | s = requests.session()
178 | # s.proxies = {'https': '101.200.127.149:3129', }
179 |
180 | # 获取签到地址
181 | try:
182 | res = s.get(main_url + '/k_misign-sign.html', cookies=cookies, headers=headers, timeout=30)
183 | rhtml = etree.HTML(res.text)
184 | # cookiejar_to_json(res.cookies)
185 | # print(res.text)
186 | qiandao_url = rhtml.xpath('//*[@id="JD_sign"]/@href')[0]
187 | # print(qiandao_url)
188 | except:
189 | # print('今日已签到')
190 | checkIn_status = 0
191 |
192 | try:
193 | s.get(main_url + '/' + qiandao_url, cookies=cookies, headers=headers, timeout=30, verify=False)
194 | # print('签到成功')
195 | checkIn_status = 1
196 | except Exception as e:
197 | # print(e)
198 | checkIn_status = 0
199 | printUserInfo()
200 |
201 | send('司机社签到', send_content)
202 |
203 |
204 | # 获取用户积分信息
205 | def printUserInfo():
206 | headers = {
207 | 'referer': main_url + '/',
208 | 'upgrade-insecure-requests': '1',
209 | 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.134 Safari/537.36 Edg/103.0.1264.77'
210 | }
211 | s = requests.session()
212 | # 关闭多余连接
213 | s.keep_alive = False
214 | # 使用代理服务
215 | # s.proxies = {"https": "101.200.127.149:3129"}
216 |
217 | try:
218 | res = s.request("GET", main_url + sign_url, cookies=cookies, headers=headers, timeout=30, verify=False)
219 | # print(res.text)
220 | rhtml = etree.HTML(res.text)
221 | except Exception as e:
222 | print('访问用户信息失败,Cookie失效')
223 | print(e)
224 | # 签到排名
225 | qiandao_num = rhtml.xpath('//*[@id="qiandaobtnnum"]/@value')[0]
226 | # 连续签到天数
227 | lxdays = rhtml.xpath('//*[@id="lxdays"]/@value')[0]
228 | # 总签到天数
229 | lxtdays = rhtml.xpath('//*[@id="lxtdays"]/@value')[0]
230 | # 签到等级
231 | lxlevel = rhtml.xpath('//*[@id="lxlevel"]/@value')[0]
232 | # 签到获取车票奖励数
233 | lxreward = rhtml.xpath('//*[@id="lxreward"]/@value')[0]
234 | # 格式化签到信息内容
235 | lxqiandao_content = f'签到排名:{qiandao_num}\n签到等级:Lv.{lxlevel}\n连续签到:{lxdays} 天\n签到总数:{lxtdays} 天\n签到奖励:{lxreward}\n'
236 |
237 | try:
238 | res = s.request("GET", main_url + '/home.php?mod=space', cookies=cookies, headers=headers, timeout=30,
239 | verify=False)
240 | time.sleep(1)
241 | # print(res.text)
242 | # print(res.status_code)
243 | rhtml = etree.HTML(res.text)
244 | # 账户名称
245 | xm = rhtml.xpath('//*[@id="ct"]/div/div[2]/div/div[1]/div[1]/h2[1]/text()')[0].replace("\r\n", "")
246 | # 当前车票数
247 | cp = rhtml.xpath('//*[@id="psts"]/ul/li[4]/text()')
248 | # 当前积分
249 | jf = rhtml.xpath('//*[@id="psts"]/ul/li[2]/text()')
250 | # 当前威望
251 | ww = rhtml.xpath('//*[@id="psts"]/ul/li[3]/text()')
252 | # 当前贡献
253 | gx = rhtml.xpath('//*[@id="psts"]/ul/li[5]/text()')
254 | except Exception as e:
255 | print('访问用户信息失败,可能存在网络波动')
256 | print(e)
257 | # exit(0)
258 | # 格式化输出内容并居中
259 | xm = "账户【" + xm + "】"
260 | xm = xm.center(24, '=')
261 |
262 | print(xm)
263 | print(
264 | f'签到状态: {checkIn_content[checkIn_status]} \n{lxqiandao_content} \n当前积分: {jf[0]}\n当前威望: {ww[0]}\n当前车票: {cp[0]}\n当前贡献: {gx[0]}\n\n')
265 | # exit(0)
266 | global send_content
267 | send_content += f'{xm}\n签到状态: {checkIn_content[checkIn_status]} \n{lxqiandao_content} \n当前积分: {jf[0]}\n当前威望: {ww[0]}\n当前车票: {cp[0]}\n当前贡献: {gx[0]}\n\n'
268 |
269 |
270 | # 阿里云函数入口
271 | def handler(event, context):
272 | try:
273 | _postdata = os.environ['XSIJISHE']
274 | except Exception:
275 | print('未设置环境变量 XSIJISHE')
276 | exit(0)
277 | if get_new_url():
278 | start(_postdata)
279 | exit(0)
280 |
281 |
282 | if __name__ == '__main__':
283 | handler('', '')
--------------------------------------------------------------------------------
/pcr532.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf8 -*-
2 |
3 | """
4 | cron: 12 8 * * *
5 | new Env('pcr532签到');
6 | 环境变量名称:PCR532_QD
7 | 账号密码使用 user&pwd 格式,多个账号使用@间隔
8 | """
9 | import requests
10 | import os
11 | import base64
12 | import time
13 | import re
14 | from sendNotify import send
15 | import urllib3
16 |
17 | urllib3.disable_warnings()
18 |
19 |
20 | def start(postdata):
21 | headers = {
22 | 'Content-Type': 'application/x-www-form-urlencoded'
23 | }
24 |
25 | info = ''
26 | name = ''
27 | pwd = ''
28 | glod = 0
29 | # 账号数据按格式分割
30 | try:
31 | payload = re.split('@|\n', postdata)
32 | print('检测到', len(payload), '个账号信息\n')
33 | # info = '发现 ' + str(len(payload)) + ' 个账号信息\n\n'
34 | except:
35 | print('环境变量格式错误, 程序退出')
36 | exit(0)
37 |
38 | # 循环每个账号信息进行签到
39 | for index, i in enumerate(payload):
40 | try:
41 | u = i.split('&')
42 | # 提交内容格式化,密码为base64编码后的字符串
43 | name = u[0]
44 | pwd = base64.b64encode(u[1].encode()).decode('utf8')
45 | p = 'username=' + name + '&passc=' + pwd
46 | except:
47 | print('账号参数格式错误')
48 | break
49 | try:
50 | user = name.replace(name[3:-4], '*' * len(name[3:-4]))
51 | response = requests.request("POST", 'https://www.rfidfans.com/upload/qiandao.php', headers=headers, data=p,
52 | verify=False, timeout=30)
53 | days = re.findall(r"连续(.*)天打卡", response.text)[0]
54 | golds = re.findall(r"奖励(\d+)个金币(.*)", response.text)[0][0]
55 | glod = get_glod(name, pwd)
56 | # info += f'账号 {user} 第{str(days)}天签到, 获得{str(golds)}个金币\n'
57 | info += f'==========账号 {index + 1}==========\n账 号:{user}\n签到状态:签到成功\n签到天数:{days}\n获得金币:{golds}\n金币总数:{glod}\n\n'
58 | print(
59 | f'==========账号 {index + 1}==========\n账 号:{user}\n签到状态:签到成功\n签到天数:{days}\n获得金币:{golds}\n金币总数:{glod}\n\n')
60 | except:
61 | try:
62 | if response.text.index('今天已经签过了'):
63 | info += f'账号 {user} 今天已签到\n'
64 | print(f'账号 {user} 今天已签到')
65 | except:
66 | info += f'账号 {user} 签到失败\n'
67 | print(f'账号 {user} 签到失败')
68 | # 间隔3秒,防止提交过快
69 | time.sleep(3)
70 |
71 | send("Pcr532签到结果", '\n' + info)
72 |
73 |
74 | def get_glod(name, pwd):
75 | headers = {
76 | 'Content-Type': 'application/x-www-form-urlencoded',
77 | 'host': 'www.rfidfans.com'
78 | }
79 | p = 'passB=cG41MzJjYXJkcmVhZGVy&passA=cHJpdmF0ZWluZm8=&username=' + name + '&passc=' + pwd
80 | try:
81 | res = requests.request("POST", 'https://www.rfidfans.com/upload/info_search.php', headers=headers, data=p,
82 | verify=False, timeout=30).json()
83 | return int(res[0]["jinbi"])
84 | except:
85 | pass
86 | return 0
87 |
88 |
89 | if __name__ == '__main__':
90 | try:
91 | _postdata = os.environ['PCR532_QD']
92 | except Exception:
93 | print('未设置环境变量 PCR532_QD')
94 | exit(0)
95 | start(_postdata)
96 |
--------------------------------------------------------------------------------
/sendNotify.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # _*_ coding:utf-8 _*_
3 |
4 | # Modify: Kirin
5 |
6 | import sys
7 | import os, re
8 | import requests
9 | import json
10 | import time
11 | import hmac
12 | import hashlib
13 | import base64
14 | import urllib.parse
15 | from requests.adapters import HTTPAdapter
16 | from urllib3.util import Retry
17 |
18 | cur_path = os.path.abspath(os.path.dirname(__file__))
19 | root_path = os.path.split(cur_path)[0]
20 | sys.path.append(root_path)
21 |
22 | # 通知服务
23 | BARK = '' # bark服务,自行搜索; secrets可填;
24 | BARK_PUSH = '' # bark自建服务器,要填完整链接,结尾的/不要
25 | SCKEY = '' # Server酱的SCKEY; secrets可填
26 | TG_BOT_TOKEN = '' # tg机器人的TG_BOT_TOKEN; secrets可填1407203283:AAG9rt-6RDaaX0HBLZQq0laNOh898iFYaRQ
27 | TG_USER_ID = '' # tg机器人的TG_USER_ID; secrets可填 1434078534
28 | TG_API_HOST = '' # tg 代理api
29 | TG_PROXY_IP = '' # tg机器人的TG_PROXY_IP; secrets可填
30 | TG_PROXY_PORT = '' # tg机器人的TG_PROXY_PORT; secrets可填
31 | DD_BOT_ACCESS_TOKEN = '' # 钉钉机器人的DD_BOT_ACCESS_TOKEN; secrets可填
32 | DD_BOT_SECRET = '' # 钉钉机器人的DD_BOT_SECRET; secrets可填
33 | QQ_SKEY = '' # qq机器人的QQ_SKEY; secrets可填
34 | QQ_MODE = '' # qq机器人的QQ_MODE; secrets可填
35 | QYWX_AM = '' # 企业微信
36 | QYWX_KEY = '' # 企业微信BOT
37 | PUSH_PLUS_TOKEN = '' # 微信推送Plus+
38 |
39 | notify_mode = []
40 |
41 | message_info = ''''''
42 |
43 | # GitHub action运行需要填写对应的secrets
44 | if "BARK" in os.environ and os.environ["BARK"]:
45 | BARK = os.environ["BARK"]
46 | if "BARK_PUSH" in os.environ and os.environ["BARK_PUSH"]:
47 | BARK_PUSH = os.environ["BARK_PUSH"]
48 | if "SCKEY" in os.environ and os.environ["SCKEY"]:
49 | SCKEY = os.environ["SCKEY"]
50 | if "TG_BOT_TOKEN" in os.environ and os.environ["TG_BOT_TOKEN"] and "TG_USER_ID" in os.environ and os.environ[
51 | "TG_USER_ID"]:
52 | TG_BOT_TOKEN = os.environ["TG_BOT_TOKEN"]
53 | TG_USER_ID = os.environ["TG_USER_ID"]
54 | if "TG_API_HOST" in os.environ and os.environ["TG_API_HOST"]:
55 | TG_API_HOST = os.environ["TG_API_HOST"]
56 | if "DD_BOT_ACCESS_TOKEN" in os.environ and os.environ["DD_BOT_ACCESS_TOKEN"] and "DD_BOT_SECRET" in os.environ and \
57 | os.environ["DD_BOT_SECRET"]:
58 | DD_BOT_ACCESS_TOKEN = os.environ["DD_BOT_ACCESS_TOKEN"]
59 | DD_BOT_SECRET = os.environ["DD_BOT_SECRET"]
60 | if "QQ_SKEY" in os.environ and os.environ["QQ_SKEY"] and "QQ_MODE" in os.environ and os.environ["QQ_MODE"]:
61 | QQ_SKEY = os.environ["QQ_SKEY"]
62 | QQ_MODE = os.environ["QQ_MODE"]
63 | # 获取pushplus+ PUSH_PLUS_TOKEN
64 | if "PUSH_PLUS_TOKEN" in os.environ:
65 | if len(os.environ["PUSH_PLUS_TOKEN"]) > 1:
66 | PUSH_PLUS_TOKEN = os.environ["PUSH_PLUS_TOKEN"]
67 | # print("已获取并使用Env环境 PUSH_PLUS_TOKEN")
68 | # 获取企业微信应用推送 QYWX_AM
69 | if "QYWX_AM" in os.environ:
70 | if len(os.environ["QYWX_AM"]) > 1:
71 | QYWX_AM = os.environ["QYWX_AM"]
72 |
73 | if "QYWX_KEY" in os.environ:
74 | if len(os.environ["QYWX_KEY"]) > 1:
75 | QYWX_KEY = os.environ["QYWX_KEY"]
76 | # print("已获取并使用Env环境 QYWX_AM")
77 |
78 | if BARK:
79 | notify_mode.append('bark')
80 | # print("BARK 推送打开")
81 | if BARK_PUSH:
82 | notify_mode.append('bark')
83 | # print("BARK 推送打开")
84 | if SCKEY:
85 | notify_mode.append('sc_key')
86 | # print("Server酱 推送打开")
87 | if TG_BOT_TOKEN and TG_USER_ID:
88 | notify_mode.append('telegram_bot')
89 | # print("Telegram 推送打开")
90 | if DD_BOT_ACCESS_TOKEN and DD_BOT_SECRET:
91 | notify_mode.append('dingding_bot')
92 | # print("钉钉机器人 推送打开")
93 | if QQ_SKEY and QQ_MODE:
94 | notify_mode.append('coolpush_bot')
95 | # print("QQ机器人 推送打开")
96 |
97 | if PUSH_PLUS_TOKEN:
98 | notify_mode.append('pushplus_bot')
99 | # print("微信推送Plus机器人 推送打开")
100 | if QYWX_AM:
101 | notify_mode.append('wecom_app')
102 | # print("企业微信机器人 推送打开")
103 |
104 | if QYWX_KEY:
105 | notify_mode.append('wecom_key')
106 | # print("企业微信机器人 推送打开")
107 |
108 |
109 | def message(str_msg):
110 | global message_info
111 | print(str_msg)
112 | message_info = "{}\n{}".format(message_info, str_msg)
113 | sys.stdout.flush()
114 |
115 |
116 | def bark(title, content):
117 | print("\n")
118 | if BARK:
119 | try:
120 | response = requests.get(
121 | f"""https://api.day.app/{BARK}/{title}/{urllib.parse.quote_plus(content)}""").json()
122 | if response['code'] == 200:
123 | print('推送成功!')
124 | else:
125 | print('推送失败!')
126 | except:
127 | print('推送失败!')
128 | if BARK_PUSH:
129 | try:
130 | response = requests.get(
131 | f"""{BARK_PUSH}/{title}/{urllib.parse.quote_plus(content)}""").json()
132 | if response['code'] == 200:
133 | print('推送成功!')
134 | else:
135 | print('推送失败!')
136 | except:
137 | print('推送失败!')
138 | print("bark服务启动")
139 | if BARK == '' and BARK_PUSH == '':
140 | print("bark服务的bark_token未设置!!\n取消推送")
141 | return
142 |
143 |
144 | def serverJ(title, content):
145 | print("\n")
146 | if not SCKEY:
147 | print("server酱服务的SCKEY未设置!!\n取消推送")
148 | return
149 | print("serverJ服务启动")
150 | data = {
151 | "text": title,
152 | "desp": content.replace("\n", "\n\n")
153 | }
154 | response = requests.post(f"https://sc.ftqq.com/{SCKEY}.send", data=data).json()
155 | if response['errno'] == 0:
156 | print('推送成功!')
157 | else:
158 | print('推送失败!')
159 |
160 |
161 | # tg通知
162 | def telegram_bot(title, content):
163 | try:
164 | print("\n")
165 | bot_token = TG_BOT_TOKEN
166 | user_id = TG_USER_ID
167 | if not bot_token or not user_id:
168 | print("tg服务的bot_token或者user_id未设置!!\n取消推送")
169 | return
170 | print("tg服务启动")
171 | if TG_API_HOST:
172 | if 'http' in TG_API_HOST:
173 | url = f"{TG_API_HOST}/bot{TG_BOT_TOKEN}/sendMessage"
174 | else:
175 | url = f"https://{TG_API_HOST}/bot{TG_BOT_TOKEN}/sendMessage"
176 | else:
177 | url = f"https://api.telegram.org/bot{TG_BOT_TOKEN}/sendMessage"
178 |
179 | headers = {'Content-Type': 'application/x-www-form-urlencoded'}
180 | payload = {'chat_id': str(TG_USER_ID), 'text': f'{title}\n\n{content}', 'disable_web_page_preview': 'true'}
181 | proxies = None
182 | if TG_PROXY_IP and TG_PROXY_PORT:
183 | proxyStr = "http://{}:{}".format(TG_PROXY_IP, TG_PROXY_PORT)
184 | proxies = {"http": proxyStr, "https": proxyStr}
185 | try:
186 | response = requests.post(url=url, headers=headers, params=payload, proxies=proxies).json()
187 | except:
188 | print('推送失败!')
189 | if response['ok']:
190 | print('推送成功!')
191 | else:
192 | print('推送失败!')
193 | except Exception as e:
194 | print(e)
195 |
196 |
197 | def dingding_bot(title, content):
198 | timestamp = str(round(time.time() * 1000)) # 时间戳
199 | secret_enc = DD_BOT_SECRET.encode('utf-8')
200 | string_to_sign = '{}\n{}'.format(timestamp, DD_BOT_SECRET)
201 | string_to_sign_enc = string_to_sign.encode('utf-8')
202 | hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
203 | sign = urllib.parse.quote_plus(base64.b64encode(hmac_code)) # 签名
204 | print('开始使用 钉钉机器人 推送消息...', end='')
205 | url = f'https://oapi.dingtalk.com/robot/send?access_token={DD_BOT_ACCESS_TOKEN}×tamp={timestamp}&sign={sign}'
206 | headers = {'Content-Type': 'application/json;charset=utf-8'}
207 | data = {
208 | 'msgtype': 'text',
209 | 'text': {'content': f'{title}\n\n{content}'}
210 | }
211 | response = requests.post(url=url, data=json.dumps(data), headers=headers, timeout=15).json()
212 | if not response['errcode']:
213 | print('推送成功!')
214 | else:
215 | print('推送失败!')
216 |
217 |
218 | def coolpush_bot(title, content):
219 | print("\n")
220 | if not QQ_SKEY or not QQ_MODE:
221 | print("qq服务的QQ_SKEY或者QQ_MODE未设置!!\n取消推送")
222 | return
223 | print("qq服务启动")
224 | url = f"https://qmsg.zendee.cn/{QQ_MODE}/{QQ_SKEY}"
225 | payload = {'msg': f"{title}\n\n{content}".encode('utf-8')}
226 | response = requests.post(url=url, params=payload).json()
227 | if response['code'] == 0:
228 | print('推送成功!')
229 | else:
230 | print('推送失败!')
231 |
232 |
233 | # push推送
234 | def pushplus_bot(title, content):
235 | try:
236 | print("\n")
237 | if not PUSH_PLUS_TOKEN:
238 | print("PUSHPLUS服务的token未设置!!\n取消推送")
239 | return
240 | print("PUSHPLUS服务启动")
241 | url = 'http://www.pushplus.plus/send'
242 | data = {
243 | "token": PUSH_PLUS_TOKEN,
244 | "title": title,
245 | "content": content
246 | }
247 | body = json.dumps(data).encode(encoding='utf-8')
248 | headers = {'Content-Type': 'application/json'}
249 | response = requests.post(url=url, data=body, headers=headers).json()
250 | if response['code'] == 200:
251 | print('推送成功!')
252 | else:
253 | print('推送失败!')
254 | except Exception as e:
255 | print(e)
256 |
257 |
258 | print("")
259 |
260 |
261 | def wecom_key(title, content):
262 | print("\n")
263 | if not QYWX_KEY:
264 | print("QYWX_KEY未设置!!\n取消推送")
265 | return
266 | print("QYWX_KEY服务启动")
267 | print("content" + content)
268 | headers = {'Content-Type': 'application/json'}
269 | data = {
270 | "msgtype": "text",
271 | "text": {
272 | "content": title + "\n" + content.replace("\n", "\n\n")
273 | }
274 | }
275 |
276 | print(f"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={QYWX_KEY}")
277 | response = requests.post(f"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={QYWX_KEY}", json=data,
278 | headers=headers).json()
279 | print(response)
280 |
281 |
282 | # 企业微信 APP 推送
283 | def wecom_app(title, content):
284 | try:
285 | if not QYWX_AM:
286 | print("QYWX_AM 并未设置!!\n取消推送")
287 | return
288 | QYWX_AM_AY = re.split(',', QYWX_AM)
289 | if 4 < len(QYWX_AM_AY) > 5:
290 | print("QYWX_AM 设置错误!!\n取消推送")
291 | return
292 | corpid = QYWX_AM_AY[0]
293 | corpsecret = QYWX_AM_AY[1]
294 | touser = QYWX_AM_AY[2]
295 | agentid = QYWX_AM_AY[3]
296 | try:
297 | media_id = QYWX_AM_AY[4]
298 | except:
299 | media_id = ''
300 | wx = WeCom(corpid, corpsecret, agentid)
301 | # 如果没有配置 media_id 默认就以 text 方式发送
302 | if not media_id:
303 | message = title + '\n\n' + content
304 | response = wx.send_text(message, touser)
305 | else:
306 | response = wx.send_mpnews(title, content, media_id, touser)
307 | if response == 'ok':
308 | print('推送成功!')
309 | else:
310 | print('推送失败!错误信息如下:\n', response)
311 | except Exception as e:
312 | print(e)
313 |
314 |
315 | class WeCom:
316 | def __init__(self, corpid, corpsecret, agentid):
317 | self.CORPID = corpid
318 | self.CORPSECRET = corpsecret
319 | self.AGENTID = agentid
320 |
321 | def get_access_token(self):
322 | url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken'
323 | values = {'corpid': self.CORPID,
324 | 'corpsecret': self.CORPSECRET,
325 | }
326 | req = requests.post(url, params=values)
327 | data = json.loads(req.text)
328 | return data["access_token"]
329 |
330 | def send_text(self, message, touser="@all"):
331 | send_url = 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=' + self.get_access_token()
332 | send_values = {
333 | "touser": touser,
334 | "msgtype": "text",
335 | "agentid": self.AGENTID,
336 | "text": {
337 | "content": message
338 | },
339 | "safe": "0"
340 | }
341 | send_msges = (bytes(json.dumps(send_values), 'utf-8'))
342 | respone = requests.post(send_url, send_msges)
343 | respone = respone.json()
344 | return respone["errmsg"]
345 |
346 | def send_mpnews(self, title, message, media_id, touser="@all"):
347 | send_url = 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=' + self.get_access_token()
348 | send_values = {
349 | "touser": touser,
350 | "msgtype": "mpnews",
351 | "agentid": self.AGENTID,
352 | "mpnews": {
353 | "articles": [
354 | {
355 | "title": title,
356 | "thumb_media_id": media_id,
357 | "author": "Author",
358 | "content_source_url": "",
359 | "content": message.replace('\n', '
'),
360 | "digest": message
361 | }
362 | ]
363 | }
364 | }
365 | send_msges = (bytes(json.dumps(send_values), 'utf-8'))
366 | respone = requests.post(send_url, send_msges)
367 | respone = respone.json()
368 | return respone["errmsg"]
369 |
370 |
371 | def send(title, content):
372 | """
373 | 使用 bark, telegram bot, dingding bot, serverJ 发送手机推送
374 | :param title:
375 | :param content:
376 | :return:
377 | """
378 |
379 | for i in notify_mode:
380 | if i == 'bark':
381 | if BARK or BARK_PUSH:
382 | bark(title=title, content=content)
383 | else:
384 | print('未启用 bark')
385 | continue
386 | if i == 'sc_key':
387 | if SCKEY:
388 | serverJ(title=title, content=content)
389 | else:
390 | print('未启用 Server酱')
391 | continue
392 | elif i == 'dingding_bot':
393 | if DD_BOT_ACCESS_TOKEN and DD_BOT_SECRET:
394 | dingding_bot(title=title, content=content)
395 | else:
396 | print('未启用 钉钉机器人')
397 | continue
398 | elif i == 'telegram_bot':
399 | if TG_BOT_TOKEN and TG_USER_ID:
400 | telegram_bot(title=title, content=content)
401 | else:
402 | print('未启用 telegram机器人')
403 | continue
404 | elif i == 'coolpush_bot':
405 | if QQ_SKEY and QQ_MODE:
406 | coolpush_bot(title=title, content=content)
407 | else:
408 | print('未启用 QQ机器人')
409 | continue
410 | elif i == 'pushplus_bot':
411 | if PUSH_PLUS_TOKEN:
412 | pushplus_bot(title=title, content=content)
413 | else:
414 | print('未启用 PUSHPLUS机器人')
415 | continue
416 | elif i == 'wecom_app':
417 | if QYWX_AM:
418 | wecom_app(title=title, content=content)
419 | else:
420 | print('未启用企业微信应用消息推送')
421 | continue
422 | elif i == 'wecom_key':
423 | if QYWX_KEY:
424 |
425 | for i in range(int(len(content) / 2000) + 1):
426 | wecom_key(title=title, content=content[i * 2000:(i + 1) * 2000])
427 |
428 |
429 | else:
430 | print('未启用企业微信应用消息推送')
431 | continue
432 | else:
433 | print('此类推送方式不存在')
434 |
435 |
436 | def main():
437 | send('title', 'content')
438 |
439 |
440 | if __name__ == '__main__':
441 | main()
--------------------------------------------------------------------------------
/sijishe.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf8 -*-
2 |
3 | """
4 | cron: 0 8 * * *
5 | new Env('司机社签到');
6 | 环境变量名称:XSIJISHE
7 | XSIJISHE: 存储登录的cookie信息, 使用 sijishe_login.py 进行登录后生成的 cookies.txt,将文件内容存到变量中
8 | 多个账号在XSIJISHE变量中使用@或换行间隔
9 | 青龙Python依赖, requests, lxml, selenium, msedge-selenium-tools
10 | [task_local]
11 | #司机社签到
12 | 0 8 * * * https://raw.githubusercontent.com/jzjbyq/AutoCheckIn/main/sijishe.py, tag=司机社签到, enabled=true
13 | [rewrite_local]
14 | https://sijishea.com url script-request-header https://raw.githubusercontent.com/jzjbyq/AutoCheckIn/main/sijishe.py
15 | """
16 | import os
17 | import re
18 | import time
19 | import json
20 | from lxml import etree
21 |
22 | from sendNotify import send
23 |
24 | # 初始化签到状态值
25 | checkIn_content = '今日已签到', '签到成功', 'Cookie失效'
26 | checkIn_status = 2
27 | send_content = ''
28 | cookies = ''
29 |
30 | # 签到积分信息页面
31 | sign_url = '/k_misign-sign.html'
32 | home_url = '/home.php?mod=space'
33 |
34 | main_url = ''
35 |
36 | # 初始化浏览器信息
37 | from selenium import webdriver
38 | chrome_options = webdriver.ChromeOptions()
39 | # 设置无界面模式,也可以添加其它设置
40 | chrome_options.add_argument('--headless')
41 | chrome_options.add_argument('--no-sandbox')
42 | chrome_options.add_argument('--disable-gpu')
43 | chrome_options.add_argument('--disable-dev-shm-usage')
44 | driver = webdriver.Chrome(options=chrome_options)
45 |
46 | def start(postdata):
47 | # 账号数据按格式分割
48 | global send_content
49 | global main_url
50 | try:
51 | payload = re.split('@|\n', postdata)
52 | print('发现', len(payload), '个账号信息\n')
53 | send_content += f'发现 {len(payload)} 个账号信息\n'
54 | # info = '发现 ' + str(len(payload)) + ' 个账号信息\n\n'
55 | except:
56 | print('环境变量格式错误, 程序退出')
57 | print(e)
58 | exit(0)
59 | global checkIn_status
60 | global cookies
61 | for i in payload:
62 | cookies = json.loads(i)
63 | # 获取登录页面地址
64 | main_url = f"https://{cookies[0]['domain']}"
65 |
66 | # 获取签到地址
67 | try:
68 | res = get_page_source(main_url + home_url, cookies)
69 | rhtml = etree.HTML(res)
70 | # cookiejar_to_json(res.cookies)
71 | # print(res.text)
72 | qiandao_url = rhtml.xpath('//*[@id="k_misign_topb"]/a/@href')[0]
73 | # print(qiandao_url)
74 | except:
75 | # print('今日已签到')
76 | checkIn_status = 0
77 |
78 | try:
79 | get_page_source(main_url + '/' + qiandao_url, cookies)
80 | # print('签到成功')
81 | checkIn_status = 1
82 | except Exception as e:
83 | # print(e)
84 | checkIn_status = 0
85 | printUserInfo()
86 |
87 | send('司机社签到', send_content)
88 |
89 |
90 | # 获取用户积分信息
91 | def printUserInfo():
92 | try:
93 | res = get_page_source(main_url + sign_url, cookies)
94 | rhtml = etree.HTML(res)
95 | except Exception as e:
96 | print('访问用户信息失败,Cookie失效')
97 | print(e)
98 | # 签到排名
99 | qiandao_num = rhtml.xpath('//*[@id="qiandaobtnnum"]/@value')[0]
100 | # 连续签到天数
101 | lxdays = rhtml.xpath('//*[@id="lxdays"]/@value')[0]
102 | # 总签到天数
103 | lxtdays = rhtml.xpath('//*[@id="lxtdays"]/@value')[0]
104 | # 签到等级
105 | lxlevel = rhtml.xpath('//*[@id="lxlevel"]/@value')[0]
106 | # 签到获取车票奖励数
107 | lxreward = rhtml.xpath('//*[@id="lxreward"]/@value')[0]
108 | # 格式化签到信息内容
109 | lxqiandao_content = f'签到排名:{qiandao_num}\n签到等级:Lv.{lxlevel}\n连续签到:{lxdays} 天\n签到总数:{lxtdays} 天\n签到奖励:{lxreward}\n'
110 |
111 | try:
112 | res = get_page_source(main_url + home_url, cookies)
113 | rhtml = etree.HTML(res)
114 | # 账户名称
115 | xm = rhtml.xpath('//*[@id="ct"]/div/div[2]/div/div[1]/div[1]/h2[1]/text()')[0].replace("\r\n", "")
116 | # 当前车票数
117 | cp = rhtml.xpath('//*[@id="psts"]/ul/li[4]/text()')
118 | # 当前积分
119 | jf = rhtml.xpath('//*[@id="psts"]/ul/li[2]/text()')
120 | # 当前威望
121 | ww = rhtml.xpath('//*[@id="psts"]/ul/li[3]/text()')
122 | # 当前贡献
123 | gx = rhtml.xpath('//*[@id="psts"]/ul/li[5]/text()')
124 | except Exception as e:
125 | print('访问用户信息失败,可能存在网络波动')
126 | print(e)
127 | # exit(0)
128 | # 格式化输出内容并居中
129 | xm = "账户【" + xm + "】"
130 | xm = xm.center(24, '=')
131 |
132 | print(xm)
133 | print(
134 | f'签到状态: {checkIn_content[checkIn_status]} \n{lxqiandao_content} \n当前积分: {jf[0]}\n当前威望: {ww[0]}\n当前车票: {cp[0]}\n当前贡献: {gx[0]}\n\n')
135 | # exit(0)
136 | global send_content
137 | send_content += f'{xm}\n签到状态: {checkIn_content[checkIn_status]} \n{lxqiandao_content} \n当前积分: {jf[0]}\n当前威望: {ww[0]}\n当前车票: {cp[0]}\n当前贡献: {gx[0]}\n\n'
138 |
139 | def get_page_source(web_url, cookies):
140 | time.sleep(3)
141 | driver.get(web_url)
142 | driver.delete_all_cookies()
143 | # cookies_list = json.loads(cookies)
144 | cookies_list = cookies
145 | # 方法1 将expiry类型变为int
146 | for cookie in cookies_list:
147 | # 并不是所有cookie都含有expiry 所以要用dict的get方法来获取
148 | if isinstance(cookie.get('expiry'), float):
149 | cookie['expiry'] = int(cookie['expiry'])
150 | driver.add_cookie(cookie)
151 | driver.refresh()
152 | source = driver.page_source
153 | time.sleep(3)
154 | return source
155 |
156 | # 阿里云函数入口
157 | def handler(event, context):
158 | try:
159 | _postdata = os.environ['XSIJISHE']
160 | except Exception:
161 | print('未设置正确的环境变量 XSIJISHE')
162 | exit(0)
163 | start(_postdata)
164 | driver.quit()
165 | exit(0)
166 |
167 |
168 | if __name__ == '__main__':
169 | handler('', '')
--------------------------------------------------------------------------------
/sijishe_login.py:
--------------------------------------------------------------------------------
1 | """
2 | 使用该脚本进行登录
3 | 登录后会保存相应的cookie信息到 cookies.txt
4 | """
5 | import time
6 | import json
7 | from selenium import webdriver
8 |
9 | options = webdriver.ChromeOptions()
10 | options.binary_location = "chrome-win64/chrome.exe"
11 | driver = webdriver.Chrome(options=options, executable_path='webdriver/chromedriver.exe')
12 | # 自行替换下边的域名为你可以访问的
13 | driver.get('https://sjs47.me/home.php?mod=space')
14 |
15 | # 20秒后自动保存,请在20秒内登录操作完成, 觉得不够还可以修改延长
16 | time.sleep(20)
17 | with open('cookies.txt','w') as f:
18 | # 将cookies保存为json格式
19 | f.write(json.dumps(driver.get_cookies()))
20 | driver.quit()
--------------------------------------------------------------------------------