加载中...
不想等待可以点我关掉
本文是该文章的一部分: 网站更新 - Thun888

一直以来友链页面使用的是预先截图的图片,后来换用了thum.io,不过免费版本的还是太差劲了,后来试了一大堆项目都不太满意,最后修了下zkeq/Python-WebSite-Screenshot,效果如图(自动更新)

本站_lastest.png (1280×720)
哔哩哔哩_lastest.png (1920×1080)

配置:

  1. Fork仓库
  2. 修改config.yaml
  3. 修改main.py中外部友链导入
  4. 启用Action的写权限
  5. 运行Action!
config.yaml(Demo)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
list:
- url: https://www.bilibili.com
timeout: 10
real_time_out: 5
height: 1080
width: 1920
full_page: 2 #原先配置可以选择不同的截图方式,但我只保留了这种
- url: https://blog.hzchu.top
timeout: 10
real_time_out: 5
height: 720
width: 1280
full_page: 2

host: #指定ip功能
- domain: blog.mc-sep.top
ipaddr: 35.212.202.85
main.py
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
...
if __name__ == "__main__":
# 读取配置文件
with open("config.yaml", "r") as f:
data = yaml.safe_load(f)["list"]

# 导入友链信息
try:
# print("------------------------------")
print("正在获取友链信息")
- response = requests.get("https://blog.hzchu.top/data/friends.json")
+ response = requests.get("https://yourDomain/friends.json")
if response.status_code != 200:
print("请求失败")
friends_data = response.json()["friends"]
# 遍历友链信息
for i in friends_data:
url = i[1]
data.append({
"url": url,
"timeout": 30,
"width": 1050, # 外部友链默认配置,按需修改
"height": 700,
"real_time_out": 10,
"full_page": 2,
})
...

最后Summer给我丢了个wr.do早知道就不折腾了,支持自部署,也可以用它提供的在线服务