GithubHelp home page GithubHelp logo

mojiebuddhist / ipdata Goto Github PK

View Code? Open in Web Editor NEW

This project forked from a76yyyy/ipdata

0.0 1.0 0.0 64.73 MB

纯真IP数据库镜像 / ZXinc_IPv6数据库镜像及MySQL脚本同步更新 for Python3

License: MIT License

Python 98.94% Batchfile 1.06%

ipdata's Introduction

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

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

ipdata's People

Contributors

a76yyyy avatar deepsource-autofix[bot] avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.