前言

科研通如果你不知道是什么的话,其实他就是一个文献求助平台某些期刊的文献你无法下载的话,可以在那里发布文献求助,可以很快获取完整文献。对于研究人员而言,我还是很推荐的。

脚本的话是去年写的了,主要还是在科研通上签到太麻烦了,我就尝试使用自动化的方法寻求解决方案了。

image-20220412205834391

其实更多的是,我个人信奉一个理论:如果一个事情需要重复做,且占用时间超过 15 秒,那么你就需要考虑自动化去完成了。

当时我集中弄了两个自动化的解决方案:

  • 基于本地浏览器的可视化编程自动化脚本(只能实现单用户签到)
  • 基于 Python 自动化签到脚本(实现多用户批量同时签到,给你的师弟师妹最好的礼物🤣)

这两个解决方案各有优缺点,我会在最后简单说明,对于懒得部署使用的同学,也可以填写我创建的收集表,提供相关的信息,我可以公益在服务器上批量签到。

解决方案

本地浏览器

这个解决方案是基于本地浏览器进行的,是利用了开源的浏览器插件 Automa 。这个插件可以实现模块化,可视化的编程实现在浏览器上的任何自动化操作。

image-20251123111310599

插件安装去官网访问安装即可,Free ~

我的实现思路很简单

  1. 首先在后台打开新的标签页
  2. 访问科研通网站(前提是你已经登陆过一次了)
  3. 判断签到按钮对象是否存在
  4. 存在就点击签到
  5. 然后关闭这个后台标签页

最后设置,脚本每天早上和晚上自动执行即可。唯一的缺点就是因为脚本是基于浏览器插件的,所以你需要保持电脑不关机,而且浏览器后台在运行中

如果有伙伴需要,脚本内容是

1
{"extVersion":"1.29.12","name":"科研通签到","icon":"riGlobalLine","table":[{"id":"HCTZH","name":"FindButton","type":"boolean"}],"version":"1.29.4","drawflow":{"edges":[{"class":"connected-edges","data":{},"events":{},"id":"vueflow__edge-w1ihw9xw1ihw9x-output-1-aoc2mlhaoc2mlh-input-1","label":"","markerEnd":"arrowclosed","selectable":true,"source":"w1ihw9x","sourceHandle":"w1ihw9x-output-1","sourceX":308,"sourceY":155.5,"target":"aoc2mlh","targetHandle":"aoc2mlh-input-1","targetX":268.9789930555555,"targetY":367.09225694444444,"type":"custom","updatable":true},{"data":{},"events":{},"id":"vueflow__edge-6nan3v16nan3v1-output-1-0sqh02d0sqh02d-input-1","label":"","markerEnd":"arrowclosed","selectable":true,"source":"6nan3v1","sourceHandle":"6nan3v1-output-1","sourceX":1540,"sourceY":94.5,"target":"0sqh02d","targetHandle":"0sqh02d-input-1","targetX":1586.8406293402777,"targetY":133.86472985161677,"type":"custom","updatable":true},{"data":{},"events":{},"id":"vueflow__edge-0sqh02d0sqh02d-output-1-ttjxxeyttjxxey-input-1","label":"","markerEnd":"arrowclosed","selectable":true,"source":"0sqh02d","sourceHandle":"0sqh02d-output-1","sourceX":1818.8406293402777,"sourceY":133.86472985161677,"target":"ttjxxey","targetHandle":"ttjxxey-input-1","targetX":1892,"targetY":94.5,"type":"custom","updatable":true},{"animated":true,"data":{},"events":{},"id":"vueflow__edge-plm5dvtplm5dvt-output-GxtVebFC-ispzULroHP-f-oho8o7doho8o7d-input-1","label":"","markerEnd":"arrowclosed","selectable":true,"source":"plm5dvt","sourceHandle":"plm5dvt-output-GxtVebFC-ispzULroHP-f","sourceX":989,"sourceY":256.88751220703125,"target":"oho8o7d","targetHandle":"oho8o7d-input-1","targetX":1058.8839930555555,"targetY":427.04993055555553,"type":"custom","updatable":true},{"data":{},"events":{},"id":"vueflow__edge-plm5dvtplm5dvt-output-JgR92FfMkn4gGjwPHiPFy-wgimrzvwgimrzv-input-1","label":"","markerEnd":"arrowclosed","selectable":true,"source":"plm5dvt","sourceHandle":"plm5dvt-output-JgR92FfMkn4gGjwPHiPFy","sourceX":989,"sourceY":208.8874969482422,"target":"wgimrzv","targetHandle":"wgimrzv-input-1","targetX":1016,"targetY":104.5,"type":"custom","updatable":true},{"data":{},"events":{},"id":"vueflow__edge-wgimrzvwgimrzv-output-1-6nan3v16nan3v1-input-1","label":"","markerEnd":"arrowclosed","selectable":true,"source":"wgimrzv","sourceHandle":"wgimrzv-output-1","sourceX":1248,"sourceY":104.5,"target":"6nan3v1","targetHandle":"6nan3v1-input-1","targetX":1308,"targetY":94.5,"type":"custom","updatable":true},{"class":"connected-edges","data":{},"events":{},"id":"vueflow__edge-aoc2mlhaoc2mlh-output-1-plm5dvtplm5dvt-input-1","label":"","markerEnd":"arrowclosed","selectable":true,"source":"aoc2mlh","sourceHandle":"aoc2mlh-output-1","sourceX":500.9789930555555,"sourceY":367.09225694444444,"target":"plm5dvt","targetHandle":"plm5dvt-input-1","targetX":692,"targetY":222.1875,"type":"custom","updatable":true},{"class":"connected-edges","data":{},"events":{},"id":"vueflow__edge-aoc2mlhaoc2mlh-output-1-8f2ubfm8f2ubfm-input-1","label":"","markerEnd":"arrowclosed","selectable":true,"source":"aoc2mlh","sourceHandle":"aoc2mlh-output-1","sourceX":500.9789930555555,"sourceY":367.09225694444444,"target":"8f2ubfm","targetHandle":"8f2ubfm-input-1","targetX":663,"targetY":471.6999816894531,"type":"custom","updatable":true}],"nodes":[{"data":{"active":false,"customUserAgent":false,"description":"科研通","disableBlock":false,"inGroup":false,"onError":{"dataToInsert":[],"enable":false,"insertData":false,"retry":false,"retryInterval":2,"retryTimes":1,"toDo":"error"},"settings":{"blockTimeout":0,"debugMode":false},"tabZoom":1,"updatePrevTab":false,"url":"https://www.ablesci.com/","userAgent":"","waitTabLoaded":true},"events":{},"id":"aoc2mlh","label":"new-tab","position":{"x":288.9789930555555,"y":331.09225694444444},"type":"BlockBasic"},{"data":{"activeInInput":false,"contextMenuName":"","contextTypes":[],"date":"","days":[],"delay":5,"description":"","disableBlock":false,"interval":60,"isUrlRegex":false,"observeElement":{"baseElOptions":{"attributeFilter":[],"attributes":false,"characterData":false,"childList":true,"subtree":false},"baseSelector":"","matchPattern":"","selector":"","targetOptions":{"attributeFilter":[],"attributes":false,"characterData":false,"childList":true,"subtree":false}},"parameters":[],"preferParamsInTab":false,"settings":{"blockTimeout":0,"debugMode":false},"shortcut":"","time":"00:00","triggers":[{"data":{"days":[{"id":0,"times":["09:00:00","15:00:00","21:00:00"]},{"id":1,"times":["09:00:00","15:00:00","21:00:00"]},{"id":3,"times":["09:00:00","15:00:00","21:00:00"]},{"id":5,"times":["09:00:00","15:00:00","21:00:00"]},{"id":2,"times":["09:00:00","15:00:00","21:00:00"]},{"id":6,"times":["09:00:00","15:00:00","21:00:00"]},{"id":4,"times":["09:00:00","15:00:00","21:00:00"]}],"time":"00:00"},"id":"nA9WZ","type":"specific-day"}],"type":"manual","url":""},"events":{},"id":"w1ihw9x","label":"trigger","position":{"x":96,"y":119.5},"type":"BlockBasic"},{"data":{"$breakpoint":false,"description":"签到","disableBlock":false,"findBy":"cssSelector","markEl":false,"multiple":false,"onError":{"dataToInsert":[],"enable":true,"insertData":false,"retry":false,"retryInterval":2,"retryTimes":1,"toDo":"error"},"selector":"button.layui-btn-danger","settings":{"blockTimeout":0,"debugMode":false},"waitForSelector":false,"waitSelectorTimeout":5000},"events":{},"id":"6nan3v1","label":"event-click","position":{"x":1328,"y":58.5},"type":"BlockBasic"},{"data":{"$breakpoint":false,"activeTab":false,"allWindows":false,"closeType":"tab","description":"","disableBlock":false,"url":"https://www.ablesci.com/"},"events":{},"id":"ttjxxey","label":"close-tab","position":{"x":1912,"y":58.5},"type":"BlockBasic"},{"data":{"$breakpoint":false,"disableBlock":false,"settings":{"blockTimeout":0,"debugMode":false},"time":500},"events":{},"id":"0sqh02d","label":"delay","position":{"x":1606.8406293402777,"y":75.17722222222224},"type":"BlockDelay"},{"data":{"$breakpoint":false,"activeTab":true,"allWindows":false,"closeType":"tab","description":"","disableBlock":false,"onError":{"dataToInsert":[],"enable":false,"insertData":false,"retry":false,"retryInterval":2,"retryTimes":1,"toDo":"error"},"settings":{"blockTimeout":0,"debugMode":false},"url":""},"events":{},"id":"oho8o7d","label":"close-tab","position":{"x":1078.8839930555555,"y":391.04993055555553},"type":"BlockBasic"},{"data":{"$breakpoint":false,"conditions":[{"conditions":[{"conditions":[{"id":"J88WeJNy8pw9tl2V8lcIC","items":[{"category":"value","data":{"selector":"/html/body/div[5]/div/div[2]/div[1]/div/div[3]/div[2]/button"},"id":"VPQ6eLLF9alGv3P2POJ_M","type":"element#exists"}]}],"id":"3o1ZdDZq0ADTkfqKTZAh5"}],"id":"JgR92FfMkn4gGjwPHiPFy","name":"元素存在"},{"conditions":[{"conditions":[{"id":"BSjfza7z1Pl3PHHDsiwGw","items":[{"category":"value","data":{"selector":"/html/body/div[5]/div/div[2]/div[1]/div/div[3]/div[2]/button"},"id":"kUF3PLEboOAsBaWgx787-","type":"element#notExists"}]}],"id":"bjVuEXNXfo5hiKRjsxjdH"}],"id":"GxtVebFC-ispzULroHP-f","name":"元素不存在"}],"description":"","disableBlock":false,"retryConditions":false,"retryCount":10,"retryTimeout":1000,"settings":{"blockTimeout":0,"debugMode":false}},"events":{},"id":"plm5dvt","label":"conditions","position":{"x":712,"y":119.5},"type":"BlockConditions"},{"data":{"dataList":[{"action":"default","filePath":"","isFile":false,"name":"HCTZH","type":"table","value":"True"}],"description":"","disableBlock":false,"onError":{"dataToInsert":[],"enable":false,"errorMessage":"","insertData":false,"retry":false,"retryInterval":2,"retryTimes":1,"toDo":"error"},"settings":{"blockTimeout":0,"debugMode":false}},"events":{},"id":"wgimrzv","label":"insert-data","position":{"x":1036,"y":68.5},"type":"BlockBasic"},{"data":{"description":"","disableBlock":false,"iconUrl":"","imageUrl":"","message":"","title":"Hello world!"},"events":{},"id":"8f2ubfm","label":"notification","position":{"x":683,"y":435.6999816894531},"type":"BlockBasic"}],"position":[0,0],"viewport":{"x":0,"y":0,"zoom":1},"zoom":1},"settings":{"blockDelay":0,"debugMode":false,"defaultColumnName":"column","execContext":"popup","executedBlockOnWeb":false,"inputAutocomplete":true,"insertDefaultColumn":false,"notification":true,"onError":"stop-workflow","publicId":"","restartTimes":3,"reuseLastState":false,"saveLog":true,"tabLoadTimeout":30000},"globalData":"{\n\t\"key\": \"value\"\n}","description":"","includedWorkflows":{}}

你只需要把这个内容保存为 json 文件,然后导入 Automa 插件里面就可以了。

但是我不得不提醒,他的最新版的这个插件,对于自动点击触发逻辑应该是变化了,现在他需要标签页获取焦点才会点击,所以要么下载老版本,要不就需要微调一下自动点击的逻辑。

很明显,这不是最优解决方案哈哈哈,因为你会关电脑,你也有可能几天不用电脑。所以我们的终极解决方案在下面

Python 自动化

这个是目前的终极解决方案,脚本功能包括:

  1. 批量多用户签到
  2. 签到结果通知到用户微信消息
  3. 管理员获取全部的用户签到结果,以应对突发签到报错
  4. 每日定时执行
  5. 不需要本地,完全运行在云端,一次部署,无需操作

这样就可以一次性给各位朋友,师哥师姐,师弟师妹们一起签到了(😀

云端签到运行主要是借助于:阿里云的云函数(当然腾讯云也可以)。

实际上这个功能在阿里云上的全称是:函数计算 FC,它是是一种事件驱动的全托管计算服务,开发者无需管理服务器等基础设施,只需编写并上传代码,函数计算便会自动准备计算资源,并以弹性、可靠的方式运行代码

函数计算默认按照资源使用量计费,根据函数配置的规格与使用时长的乘积计算资源使用量,仅在需要时分配资源并能及时释放。

微信通知借助于:Server酱服务

它是一款「手机」和「服务器」、「智能设备」之间的通信软件。说人话就是从服务器、路由器等设备上推消息到手机的工具。

最终实现效果就是每日定时给多用户签到,签到完成后会通知每个用户签到结果。稳定性而言,一次部署在我这里已经稳定运行 259 天了。

image-20251124095618694

因为微信公众号不允许挂外部链接,所以相关服务直接百度就能找到

数据准备

在开始签到之前,我们需要提供相关的数据以自动化脚本,主要是两个信息:

  • 科研通的cookie:它代表了你在科研通服务器上的身份,负责通过这个信息模拟是你在签到
  • Server酱的SendKey:它代表了你在 Server 酱上的身份,负责通过这个信息给用户本人发送通知

科研通的cookie获取方式

  1. 打开你的浏览器的开发者模式,你可以通过F12快捷键打开,或者相关设置里面打开(每个浏览器可能略微不同)
  2. 打开你的科研通网站(或者你也可以先访问科研通网站,然后再打开科研通网站)
  3. 找到【网络】,如果这个列表是空的,刷新一下网页就有了
  4. 找到科研通的这个页面,在标头里面找到Cookie项,复制整个值即可(每个人不一样,长短内容)
image-20251124100614698

Server 酱的SendKey 获取

比较简单,只需要用户注册登录后,在Key&API栏找到自己的 SendKey 即可。

image-20251124100118422

至此,你的数据准备工作就完成了。接下来就是脚本了。

脚本内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# 作者:Maxwell Lei
import requests
from datetime import datetime

def ablesci(headers, sendkey, account_name):
"""执行签到并发送结果通知"""
url = "https://www.ablesci.com/user/sign"
try:
response = requests.get(url, headers=headers)
if response.status_code == 200:
response_data = response.json()
if response_data.get('code') == 0:
result_msg = response_data.get('msg', '签到成功')
print(f"账号 [{account_name}] {result_msg}")
send_notification(sendkey, f"[{account_name}] 签到成功", result_msg)
return True, result_msg
else:
error_msg = response_data.get('msg', '签到失败')
print(f"账号 [{account_name}] {error_msg}")
send_notification(sendkey, f"[{account_name}] 签到失败", error_msg)
return False, error_msg
else:
error_msg = f"签到失败,状态码: {response.status_code}, 响应内容: {response.text}"
print(f"账号 [{account_name}] {error_msg}")
send_notification(sendkey, f"[{account_name}] 签到失败", error_msg)
return False, error_msg
except Exception as e:
error_msg = f"签到过程发生异常: {str(e)}"
print(f"账号 [{account_name}] {error_msg}")
send_notification(sendkey, f"[{account_name}] 签到异常", error_msg)
return False, error_msg

def send_notification(sendkey, title, content):
"""发送Server酱通知"""
url = f"https://sctapi.ftqq.com/{sendkey}.send"
data = {
"title": title,
"desp": content
}
try:
response = requests.post(url, data=data)
print(f"通知发送结果: {response.text}")
except Exception as e:
print(f"发送通知失败: {str(e)}")

def notify_admin(admin_sendkey, total, success, failed, failed_accounts):
"""发送管理员汇总通知"""
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
title = f"AbleSci签到汇总 - {current_time}"

# 构建详细内容
content = f"""## 签到汇总报告
- 总计尝试签到: {total}个账号
- 签到成功: {success}个账号
- 签到失败: {failed}个账号
"""

# 添加失败账号详情
if failed > 0:
content += "## 失败账号详情\n"
for account in failed_accounts:
content += f"- 账号: {account['name']}\n"
content += f" 原因: {account['reason']}\n\n"

# 发送通知
send_notification(admin_sendkey, title, content)

def main():
# 管理员的 Server 酱的 SendKey
# 负责给管理员发送全部成员的签到结果,以随时接受报错
admin_sendkey = "SCT271403TkSOUndnAIqs6t9UMqQOFzXsN"

# 批量列表
accounts = [
{
"name": "某某用户,这是一个标识名称",
"cookie": "这里填写你获取的科研通的 cookie内容,有的会很长",
"sendkey": "这里填写该用户的 Server 酱 Sendkey 负责给该用户发送个人签到结果"
},
]

# 统计信息
total_accounts = len(accounts)
success_count = 0
failed_count = 0
failed_accounts = []

for account in accounts:
cookie = account["cookie"]
sendkey = account["sendkey"]
account_name = account["name"]

headers = {
"Accept": "application/json, text/javascript, */*; q=0.01",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9",
"Cookie": cookie,
"DNT": "1",
"Referer": "https://www.ablesci.com/",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Mobile Safari/537.36",
"X-Requested-With": "XMLHttpRequest"
}

print(f"开始处理账号 [{account_name}]")
success, message = ablesci(headers=headers, sendkey=sendkey, account_name=account_name)

if success:
success_count += 1
else:
failed_count += 1
failed_accounts.append({
"name": account_name,
"reason": message
})

print("----------------------------------")

# 发送管理员汇总通知
notify_admin(admin_sendkey, total_accounts, success_count, failed_count, failed_accounts)
print(f"已发送管理员汇总通知,总计: {total_accounts},成功: {success_count},失败: {failed_count}")

def handler(event, context):
main()

当然你也可以通过整个脚本,在本地执行,不过这样就南辕北辙了不是。你可以直接和我一样,部署到云函数上,这样就可以实现,一次部署,自动签到,不需要考虑别的了。

公益服务

如果上述的内容你都不想尝试自己部署,我可以提供批量签到公益服务,毕竟我的云函数部署着一个也是签到,两个也是签到,您可以填写下面的收集表,该收集表仅7天内有效,我会给你实现自动签到。

image-20251124102825358

下面的链接和上面的二维码是一个,你可以选择访问链接一样的:【腾讯文档】科研通自动签到
https://docs.qq.com/form/page/DUXJaaFBsbkNwRVJP

结语

脚本很好,请狠狠的使用,不要让文献拖延家人们的科研步伐啊!!

最近有点忙,更新会有点慢,做了一些有趣的代码实验和我个人维护的软件更新。腾出时间会写点东西,以记录下来。

image-20251124101847154

参考内容

本篇内容无任何参考内容