1
0
mirror of synced 2024-07-07 20:45:13 +08:00

add hk url

This commit is contained in:
xueweihan 2021-07-11 12:20:50 +08:00
parent ec4e61bd43
commit 29025c2b7b
2 changed files with 10 additions and 10 deletions

View File

@ -28,8 +28,8 @@
上面内容会自动定时更新,保证最新有效。数据更新时间:{update_time}(内容无变动不会更新)
- 文件:`https://api.hellogithub.com/GitHub520/hosts`
- JSON`https://api.hellogithub.com/GitHub520/hosts.json`
- 文件:`https://raw.hellogithub.com/hosts`
- JSON`https://raw.hellogithub.com/hosts.json`
### 2.1 手动方式
@ -68,7 +68,7 @@ hosts 文件在每个系统的位置不一,详情如下:
- Type: `Remote`
- URL: `https://api.hellogithub.com/GitHub520/hosts`
- URL: `https://raw.hellogithub.com/hosts`
- Auto Refresh: 最好选 `1 hour`
@ -84,7 +84,7 @@ hosts 文件在每个系统的位置不一,详情如下:
- 名称: 随意
- URL: `https://api.hellogithub.com/GitHub520/hosts`(和上面 SwitchHosts 使用的一样)
- URL: `https://raw.hellogithub.com/hosts`(和上面 SwitchHosts 使用的一样)
如图:

View File

@ -57,7 +57,7 @@ HOSTS_TEMPLATE = """# GitHub520 Host Start
{content}
# Update time: {update_time}
# Update url: https://api.hellogithub.com/GitHub520/hosts
# Update url: https://raw.hellogithub.com/hosts
# Star me: https://github.com/521xueweihan/GitHub520
# GitHub520 Host End\n"""
@ -90,10 +90,10 @@ def write_host_file(hosts_content: str):
output_fb.write(hosts_content)
def write_json_file(hosts_dict: dict):
def write_json_file(hosts_list: list):
output_file_path = os.path.join(os.path.dirname(__file__), 'hosts.json')
with open(output_file_path, "w") as output_fb:
json.dump(hosts_dict, output_fb)
json.dump(hosts_list, output_fb)
def make_ipaddress_url(raw_url: str):
@ -157,12 +157,12 @@ def update_gitee_gist(session: requests.session, host_content):
def main():
session = requests.session()
content = ""
content_dict = {}
content_list = []
for raw_url in RAW_URL:
try:
host_name, ip = get_ip(session, raw_url)
content += ip.ljust(30) + host_name + "\n"
content_dict[ip] = host_name
content_list.append((ip, host_name,))
except Exception:
continue
@ -173,7 +173,7 @@ def main():
hosts_content = HOSTS_TEMPLATE.format(content=content, update_time=update_time)
has_change = write_file(hosts_content, update_time)
if has_change:
write_json_file(content_dict)
write_json_file(content_list)
print(hosts_content)