#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import urllib.request
aaa_name = "aaa.txt"
aaa_link = "https://aaa.aaa.aaa.com/feeds/aaa/aaa.txt"
def download_aaa_family():
try:
req = urllib.request.Request(aaa_link )
f = urllib.request.urlopen(req)
s = f.read()
s = s.decode('gbk', 'ignore')
mdir = sys.path[0] + '/'
file = open(mdir + aaa_name , 'a', 1, 'gbk')
file.write(s)
file.close()
except Exception as e:
print("Download aaa family error: {0}, {1}".format(e, e.__traceback__.tb_lineno))
return False
return True
if __name__ == "__main__":
if not download_aaa_family():
sys.exit()