1 Star 0 Fork 116

I-SHU/GitHub520

forked from klmahua/GitHub520 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
update_ips.py 1004 Bytes
一键复制 编辑 原始数据 按行查看 历史
HelloGitHub 提交于 2025-01-16 21:14 +08:00 . fix: github action bug
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#
# Author : XueWeiHan
# E-mail : 595666367@qq.com
# Date : 2025-01-16 15:27
# Desc : GitHub Action 运行的脚本
import json
from typing import Any, Optional
from retry import retry
from requests_html import HTMLSession
from common import write_hosts_content
@retry(tries=3)
def get_json(session: Any) -> Optional[list]:
url = 'https://raw.hellogithub.com/hosts.json'
try:
rs = session.get(url)
data = json.loads(rs.text)
return data
except Exception as ex:
print(f"get: {url}, error: {ex}")
raise Exception
def main() -> None:
print('Start script.')
session = HTMLSession()
content = ""
content_list = get_json(session)
for item in content_list:
content += item[0].ljust(30) + item[1] + "\n"
hosts_content = write_hosts_content(content, content_list)
print(hosts_content)
print('End script.')
if __name__ == '__main__':
main()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/i-shu/GitHub520.git
git@gitee.com:i-shu/GitHub520.git
i-shu
GitHub520
GitHub520
main

搜索帮助