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


配置:
- Fork仓库
- 修改
config.yaml - 修改
main.py中外部友链导入 - 启用Action的写权限
- 运行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: - domain: blog.mc-sep.top ipaddr: 35.212.202.85
|
main.py1 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,早知道就不折腾了,支持自部署,也可以用它提供的在线服务