mirror of
https://github.com/shmilylty/OneForAll.git
synced 2026-10-25 00:56:14 +08:00
改为类
This commit is contained in:
+9
-7
@@ -1,11 +1,13 @@
|
|||||||
import zipfile
|
import zipfile
|
||||||
import IP2Location
|
from IP2Location import IP2Location
|
||||||
from config.setting import data_storage_dir
|
from config.setting import data_storage_dir
|
||||||
|
|
||||||
|
|
||||||
zip_path = data_storage_dir.joinpath("IP2LOCATION-LITE-DB3.BIN.ZIP")
|
class IpGeoInfo(IP2Location):
|
||||||
bin_path = data_storage_dir.joinpath("IP2LOCATION-LITE-DB3.BIN")
|
def __init__(self):
|
||||||
if not bin_path.exists():
|
zip_path = data_storage_dir.joinpath("IP2LOCATION-LITE-DB3.BIN.ZIP")
|
||||||
zf = zipfile.ZipFile(zip_path)
|
bin_path = data_storage_dir.joinpath("IP2LOCATION-LITE-DB3.BIN")
|
||||||
zf.extract('IP2LOCATION-LITE-DB3.BIN', data_storage_dir)
|
if not bin_path.exists():
|
||||||
IpGeoInfo = IP2Location.IP2Location(bin_path)
|
zf = zipfile.ZipFile(zip_path)
|
||||||
|
zf.extract('IP2LOCATION-LITE-DB3.BIN', data_storage_dir)
|
||||||
|
IP2Location.__init__(self, bin_path)
|
||||||
|
|||||||
+1
-1
@@ -70,7 +70,7 @@ def deal_output(output_path):
|
|||||||
logger.log('INFOR', f'Processing resolved results')
|
logger.log('INFOR', f'Processing resolved results')
|
||||||
records = dict() # 用来记录所有域名解析数据
|
records = dict() # 用来记录所有域名解析数据
|
||||||
ip_asn = IPAsnInfo()
|
ip_asn = IPAsnInfo()
|
||||||
ip_geo = IpGeoInfo
|
ip_geo = IpGeoInfo()
|
||||||
db_path = settings.data_storage_dir.joinpath('ip2region.db')
|
db_path = settings.data_storage_dir.joinpath('ip2region.db')
|
||||||
ip_reg = IpRegInfo(db_path)
|
ip_reg = IpRegInfo(db_path)
|
||||||
with open(output_path) as fd:
|
with open(output_path) as fd:
|
||||||
|
|||||||
Reference in New Issue
Block a user