refresh.py 802 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. '''
  4. @Author : liuyuqi
  5. @Contact : liuyuqi.gov@msn.cn
  6. @Time : 2020/06/01 17:46:12
  7. @Version : 1.0
  8. @License : Copyright © 2017-2020 liuyuqi. All Rights Reserved.
  9. @Desc : 每日获取最新 host.deny
  10. '''
  11. import requests
  12. import os
  13. import sys
  14. import re
  15. import time
  16. import json
  17. import user_agent
  18. url = "http://antivirus.neu.edu.cn/ssh/lists/neu_sshbl_hosts.deny"
  19. resultFile = r'host.deny'
  20. def getData():
  21. with open(resultFile, 'w', encoding="utf8") as file:
  22. resData = requests.get(
  23. url, headers=user_agent.getheaders(), timeout=5).content.decode("utf8")
  24. file.write(resData)
  25. if __name__ == "__main__":
  26. start_time = time.time()
  27. getData()
  28. print("last time: {} s".format(time.time() - start_time))