Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
john0618 opened this issue Mar 3, 2022 · 2 comments

Comments

@john0618
Copy link

john0618 commented Mar 3, 2022

'''
此脚本需要将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缓存刷新完毕!")

@jianboy
Copy link
Owner

jianboy commented Mar 7, 2022

可以把

https://github.com/jianboy/github-host/blob/master/hosts

改为

https://git.yoqi.me/lyq/github-host/raw/master/hosts

@JohyC
Copy link

JohyC commented Mar 27, 2022

我也分享下我的代码!
https://github.com/JohyC/Hosts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants