Skip to content

我引用了由您提供的hosts,写了一个比较粗暴的py脚本。 #2

@john0618

Description

@john0618

'''
此脚本需要将hosts.txt的文件文件操作权限(修改、写入)赋予给当前user,不然会显示拒绝访问!
'''
import requests
import os

url = "https://github.com/jianboy/github-host/blob/master/hosts" # hosts源码

r = requests.get(url=url)

hosts = r.text

with open('C:\Windows\System32\drivers\etc\hosts.txt', 'w+') as f:
f.write(hosts)

os.system("ipconfig /flushdns")

print("hosts文件更新完毕,DNS缓存刷新完毕!")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions