def parsecountry(cfdbpath):
"""Parse CrimeFlare's country.zip archive into a dictionary."""
# Open country archive, parse out required data, store into a list
try:
zcountry = zipfile.ZipFile('{}/country.zip'.format(cfdbpath))
for finfo in zcountry.infolist():
ifile = zcountry.open(finfo)
for record in ifile.readlines():
try:
DOMAIN, IP, COUNTRY = record.decode('utf-8').split()
except(ValueError):
COUNTRY = ' '.join(map(str, record.decode('utf-8').split()[2:]))
_countrydict[DOMAIN] = '{}'.format(COUNTRY)
except(zipfile.BadZipfile):
print("[-] Bad checksum on downloaded archive. Try to update again.")
raise SystemExit
cflareupdate.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录