赞
踩
- #!/usr/bin/env/python3
- # -*- coding:utf-8 -*-
- import requests
-
- # 爬虫获取动态hosts
- url = "https://raw.hellogithub.com/hosts"
- res = requests.get(url).text
- res_list = [data for data in res.split("\n")]
- print(res_list)
- # 修改本地hosts
- host_path = "C:\Windows\System32\drivers\etc\hosts" + "1"
- with open(host_path, mode="a+") as f:
- all_data = f.readlines()
- f.write("\n".join(res_list))
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。