当前仓库属于暂停状态,部分功能使用受限,详情请查阅 仓库状态说明
3 Star 10 Fork 5

a76yyyy/ipdata
暂停

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

IPDATA

Update Create Release

因IPv4和IPv6数据库相继开启商业化运营模式, 当IP数据库源不再提供离线镜像时, 本仓库将尊重其要求进行存档或关闭。

纯真IPv4数据库镜像 / ZXinc_IPv6数据库镜像 & MySQL脚本/SQLite3 同步更新 for Python3(原czipdata项目) (仓库数据文件已通过release发布,commit历史初始化以优化仓库大小)

Github:https://github.com/a76yyyy/ipdata(推荐)

Gitee :https://gitee.com/a76yyyy/ipdata(更新频率较低)

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

IP查询

安装相关模块

# 使用git前请先安装git软件
git clone --depth=1 https://github.com/a76yyyy/ipdata.git
cd ipdata
# 安装gzip 解压data文件夹中的gz相关文件;
# 使用sqlite3请先安装sqlite3软件, 数据库文件在data/ipdata.db.gz压缩档内;
# 使用mysql请先安装mysql组件并导入sql脚本, sql脚本在data/ipdatabase.sql.gz压缩档内;
# 进行下述操作前请先安装python3;
pip3 install pipenv
pipenv install
pipenv shell
python

SQLite3 for Python3

from database import sqlite3_Database
from configs import config
sqlite3file = config['sqlite3'].ip_database
conn = sqlite3_Database(sqlite3file)

MySQL for Python3

from database import mysql_Database
from configs import config
conn = mysql_Database(config['mysql'].ip_database)

IPv4 查询

import ipaddress
ip = 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 查询

import ipaddress
ip = 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

API

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

Stargazers over time

Stargazers over time

MIT License Copyright (c) 2020 a76yyyy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

纯真IP数据库镜像 / ZXinc_IPv6数据库镜像及MySQL脚本同步更新 for Python3 展开 收起
Python 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/a76yyyy/ipdata.git
git@gitee.com:a76yyyy/ipdata.git
a76yyyy
ipdata
ipdata
main

搜索帮助

A270a887 8829481 3d7a4017 8829481