This repository was archived by the owner on May 13, 2022. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork8
纯真IP数据库镜像 / ZXinc_IPv6数据库镜像及MySQL脚本同步更新 for Python3 (本仓库不与a76yyyy/ipdata同步)
License
NotificationsYou must be signed in to change notification settings
ZX-Inc/zxipdb-python
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
因IPv4和IPv6数据库相继开启商业化运营模式, 当IP数据库源不再提供离线镜像时, 本仓库将尊重其要求进行存档或关闭。
纯真IPv4数据库镜像 / ZXinc_IPv6数据库镜像 & MySQL脚本/SQLite3 同步更新 for Python3 (原ipdata项目)
Github:https://github.com/ZX-Inc/zxipdb-python(推荐)
- 通过Python实现纯真IPv4数据库及ZXinc_ipv6数据库的镜像更新,数据库在data文件夹下;
- 将数据文件解析为txt格式;
- 将数据文件全量导入mysql中,请先安装mysql并启用服务;
- 将数据文件全量导入SQLite3中,请先安装SQLite3并启用服务;
- 将MySQL/SQLite3数据库中的IP数据库内的地址细分为省市区;
- 生成sql脚本文件的gz压缩文档,请先安装 gzip 并添加至系统变量(默认提供gz压缩文档, 不提供sql脚本);
- 生成SQLite3数据库db文件的gz压缩文档;
- Windows使用BAT文件实现数据库的自动更新和推送;
- 结合计划任务可实现windows的定时更新。
| 文件 | 内容 | 类型 |
|---|---|---|
| czipdata_version.bin | IPv4本地数据文件版本记录 | Binary |
| ipv6data_version.bin | IPv6本地数据文件版本记录 | Binary |
| ipdata.db | IP数据库db文件 | SQLite3 DB文件 |
| ipdatabase.sql | IP数据库sql脚本(含以下sql内容) | MySQL脚本 |
| iprange_info.sql | 纯真IPv4数据表sql脚本 | MySQL脚本 |
| ipv6_range_info.sql | ZXinc_IPv6数据表sql脚本 | MySQL脚本 |
| college_info.sql | 高校信息表sql脚本 | MySQL脚本 |
| czipdata.dat | 纯真IPv4数据文件 | IPDB源文件 |
| ipv6data.db | ZXinc_IPv6数据文件 | IPDB源文件(Not SQLite3) |
| czipdata.txt | 纯真IPv4数据文本文件 | TXT |
| ipv6data.txt | ZXinc_IPv6数据文本文件 | TXT |
| correct.json | 地址细分纠错文件 | JSON |
# 使用git前请先安装git软件git clone--depth=1 https://github.com/ZX-Inc/zxipdb-python.gitcd ipdata# 安装gzip 解压data文件夹中的gz相关文件;# 使用sqlite3请先安装sqlite3软件, 数据库文件在data/ipdata.db.gz压缩档内;# 使用mysql请先安装mysql组件并导入sql脚本, sql脚本在data/ipdatabase.sql.gz压缩档内;# 进行下述操作前请先安装python3;pip3 install pipenvpipenv installpipenv shellpython
fromdatabaseimportsqlite3_Databasefromconfigsimportconfigsqlite3file=config['sqlite3'].ip_databaseconn=sqlite3_Database(sqlite3file)
fromdatabaseimportmysql_Databasefromconfigsimportconfigconn=mysql_Database(config['mysql'].ip_database)
importipaddressip=ipaddress.IPv4Address('114.114.114.114')sql="select * from iprange_info where "+str(int(ip))+" between ip_start_num and ip_end_num "print(conn.query(sql))
importipaddressip=ipaddress.IPv6Address('2400:3200::')sql="select * from ipv6_range_info where x'"+''.join(ip.exploded.split(':'))+"' between ip_start_num and ip_end_num "print(conn.query(sql))
conn.__del__()exit()
- 实现data文件夹的分类存储;
- 实现数据库的增量更新;
- 实现Linux定时更新.
示例IPv4 API接口(暂不提供源码):https://api.a76yyyy.cn/ip?function=ipInfo¶ms1=114.114.114.114
示例IPv6 API接口(暂不提供源码):https://api.a76yyyy.cn/ip?function=ipv6Info¶ms1=2400:3200::1
About
纯真IP数据库镜像 / ZXinc_IPv6数据库镜像及MySQL脚本同步更新 for Python3 (本仓库不与a76yyyy/ipdata同步)
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.






