Skip to main content

XdbLocation

是一个离线IP地址定位库和IP定位数据管理的库

安装

稳定版本

要安装Xdb_Location,请在终端中运行以下命令:

uv add xdb_location

或者,如果你更喜欢使用 pip:

pip install xdb_location

源码安装

Xdb_Location的源文件可以从以下网址下载 Github repo.

您可以克隆公共存储库:

git clone git://github.com/gunhe/xdb_location

一旦你有了源代码的副本,你就可以用以下方式安装它:

cd xdb_location
uv pip install .

使用

from xdb_location.xdb_location import searchWithContent
target_ip_location = searchWithContent(target_ip="1.15.241.228")
print(target_ip_location)

虚拟号

虚拟号查询

查询手机号是否命中虚拟运营商号段库:

from xdb_location.virtual_phone import virtual_number_searcher

result = virtual_number_searcher("17040655743")
print(result)

返回示例:

{
    "section": "1704065",
    "area": "福建 漳州",
    "network": "联通网络",
    "provider": "天音移动",
    "company": "天音通信",
    "is_virtual_number": True,
    "phone_number": "17040655743",
}

字段说明:

字段 说明
section 手机号前 7 位号段
area 号段归属地
network 使用网络
provider 虚拟运营商品牌
company 虚拟运营商所属公司
is_virtual_number 是否命中虚拟号段库
phone_number 原始查询手机号

如果未命中虚拟号段库,is_virtual_number 为 False,其余未知字段返回 未知:

IP地理位置

最佳实践

# 程序启动前把 searchWithContent 对象缓存下来,做成一个全局对象
from xdb_location.xdb_location import searchWithContentCache

# 使用searchWithContent 对象来查询
searcher = searchWithContentCache()
target_ip_location = searcher.search("1.15.241.228")
print(target_ip_location)

# 程序结束时候释放内存空间
searcher.close()

数据生成

git clone https://github.com/gunhe/xdb_location.git
cd xdb_location
# 测试数据生成
uv run xdb_location ./src/xdb_location/data/ip.test.txt ./ip2region.test.xdb
# ipv4 数据生成
uv run xdb_location ./src/xdb_location/data/ipv4_source.txt ./ip2region.ipv4_source.xdb
# ipv6 数据生成
uv run xdb_location ./src/xdb_location/data/ipv6_source.txt ./ip2region.ipv6_source.xdb

参考

uv

Publishing your package

Using uv in GitHub Actions

Typer

Cookiecutter

audreyfeldroy/cookiecutter-pypackage

https://github.com/lionsoul2014/ip2region

Metadata

Release files for xdb_location 0.1.39

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xdb_location 0.1.39
File Size Uploaded Provenance
xdb_location-0.1.39.tar.gz 33.0 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for xdb_location 0.1.39
File Interpreter ABI Platform
xdb_location-0.1.39-py3-none-any.whl Python 3 none any Details

Total release size: 65.9 MB

Release files / xdb_location-0.1.39.tar.gz

Download URL xdb_location-0.1.39.tar.gz
Size 33.0 MB
Tags Source
SHA-256 checksum
How to use checksums
f162863d8d2067b3cdedb87a8e5376ed6d7ac6c2122fb58ae158cbbf37960fae
BLAKE2b-256 checksum
How to use checksums
aa1d8e0e53793812559e1e6ce4ef9be0474cc16134f6e2e55826f63fbef0ead9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / xdb_location-0.1.39-py3-none-any.whl

Download URL xdb_location-0.1.39-py3-none-any.whl
Size 33.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
c88bbd9fde669be4b0b7c9814bf3fee1c71d6fd20a5c9e7874e8c37d2dbdd054
BLAKE2b-256 checksum
How to use checksums
1f7a9a6951af5c6cd64d4596d9cda6237be133a30aa022a73cab50bad843542a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for xdb_location 0.1.39

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page