Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 13, 2022. It is now read-only.
/zxipdb-pythonPublic archive

纯真IP数据库镜像 / ZXinc_IPv6数据库镜像及MySQL脚本同步更新 for Python3 (本仓库不与a76yyyy/ipdata同步)

License

NotificationsYou must be signed in to change notification settings

ZX-Inc/zxipdb-python

Repository files navigation

ZXIPDB-Python

UpdateCreate Release

纯真IPv4数据库镜像 / ZXinc_IPv6数据库镜像 & MySQL脚本/SQLite3 同步更新 for Python3 (原ipdata项目)

Github:https://github.com/ZX-Inc/zxipdb-python(推荐)

Flag Counter

功能

  1. 通过Python实现纯真IPv4数据库及ZXinc_ipv6数据库的镜像更新,数据库在data文件夹下;
  2. 将数据文件解析为txt格式;
  3. 将数据文件全量导入mysql中,请先安装mysql并启用服务;
  4. 将数据文件全量导入SQLite3中,请先安装SQLite3并启用服务;
  5. 将MySQL/SQLite3数据库中的IP数据库内的地址细分为省市区;
  6. 生成sql脚本文件的gz压缩文档,请先安装 gzip 并添加至系统变量(默认提供gz压缩文档, 不提供sql脚本);
  7. 生成SQLite3数据库db文件的gz压缩文档;
  8. Windows使用BAT文件实现数据库的自动更新和推送;
  9. 结合计划任务可实现windows的定时更新。

数据文件

文件内容类型
czipdata_version.binIPv4本地数据文件版本记录Binary
ipv6data_version.binIPv6本地数据文件版本记录Binary
ipdata.dbIP数据库db文件SQLite3 DB文件
ipdatabase.sqlIP数据库sql脚本(含以下sql内容)MySQL脚本
iprange_info.sql纯真IPv4数据表sql脚本MySQL脚本
ipv6_range_info.sqlZXinc_IPv6数据表sql脚本MySQL脚本
college_info.sql高校信息表sql脚本MySQL脚本
czipdata.dat纯真IPv4数据文件IPDB源文件
ipv6data.dbZXinc_IPv6数据文件IPDB源文件(Not SQLite3)
czipdata.txt纯真IPv4数据文本文件TXT
ipv6data.txtZXinc_IPv6数据文本文件TXT
correct.json地址细分纠错文件JSON

IP查询

安装相关模块

# 使用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

SQLite3 for Python3

fromdatabaseimportsqlite3_Databasefromconfigsimportconfigsqlite3file=config['sqlite3'].ip_databaseconn=sqlite3_Database(sqlite3file)

MySQL for Python3

fromdatabaseimportmysql_Databasefromconfigsimportconfigconn=mysql_Database(config['mysql'].ip_database)

IPv4 查询

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))

IPv6 查询

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()

TODO

  1. 实现data文件夹的分类存储;
  2. 实现数据库的增量更新;
  3. 实现Linux定时更新.

图片

image

image

image

image

image

示例IPv4 API接口(暂不提供源码):https://api.a76yyyy.cn/ip?function=ipInfo&params1=114.114.114.114

image

示例IPv6 API接口(暂不提供源码):https://api.a76yyyy.cn/ip?function=ipv6Info&params1=2400:3200::1

image

About

纯真IP数据库镜像 / ZXinc_IPv6数据库镜像及MySQL脚本同步更新 for Python3 (本仓库不与a76yyyy/ipdata同步)

Topics

Resources

License

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp