ipip-ipdb-hp


Nameipip-ipdb-hp JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/magicbear/ipip-ipdb-hp
SummaryIPIP.net non-officially supported IP database ipdb format parsing library
upload_time2024-02-27 13:42:22
maintainer
docs_urlNone
authorMagicBear
requires_python
licenseApache-2.0
keywords ipdb ipip
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ipip-ipdb-hp
High performance IPIP.net unofficially database ipdb format parsing library

# Python Parse ipdb file

## Installing
```
python3 setup.py build
python3 setup.py install
```

## 官方库性能对比
### C Version
```
python3 ipdotnet_benchmark.py
Load: 0.034990s  List Used: 0.2513652s  QPS: 397826/s
Load: 0.286393s  Dict Used: 0.2991660s  QPS: 334262/s
```
### Py Version
```
Load: 0.074412s   List Used: 4.2106075s  QPS: 23750/s
Load: 4.285052s   Map  Used: 4.4340391s  QPS: 22553/s
```

## Code Example
### 适用于IPDB格式的每周高级版,每日标准版,每日高级版,每日专业版,每日旗舰版
  <pre><code>
import ipdb

db = ipdb.City("/path/to/city.ipv4.ipdb")
# db.reload("/path/to/city.ipv4.ipdb") # update ipdb database file reload data
print(db.is_ipv4(), db.is_ipv6())
print(db.languages()) # support language
print(db.fields()) #  support fields
print(db.build_time()) #  build database time
print(db.find("1.1.1.1", "CN")) #  query ip return array
# print(db.find(u"1.1.1.1", "CN")) #  Python 2.7
print(db.find_map("8.8.8.8", "CN")) #  query ip return dict
print(db.find_info("118.28.1.1", "CN").country_name) 
  </pre></code>

### 地级市精度库数据字段说明
<pre>
country_name : 国家名字 (每周高级版及其以上版本包含)
region_name  : 省名字   (每周高级版及其以上版本包含)
city_name    : 城市名字 (每周高级版及其以上版本包含)
owner_domain : 所有者   (每周高级版及其以上版本包含)
isp_domain  : 运营商 (每周高级版与每日高级版及其以上版本包含)
latitude  :  纬度   (每日标准版及其以上版本包含)
longitude : 经度    (每日标准版及其以上版本包含)
timezone : 时区     (每日标准版及其以上版本包含)
utc_offset : UTC时区    (每日标准版及其以上版本包含)
china_admin_code : 中国行政区划代码 (每日标准版及其以上版本包含)
idd_code : 国家电话号码前缀 (每日标准版及其以上版本包含)
country_code : 国家2位代码  (每日标准版及其以上版本包含)
continent_code : 大洲代码   (每日标准版及其以上版本包含)
idc : IDC |  VPN   (每日专业版及其以上版本包含)
base_station : 基站 | WIFI (每日专业版及其以上版本包含)
country_code3 : 国家3位代码 (每日专业版及其以上版本包含)
european_union : 是否为欧盟成员国: 1 | 0 (每日专业版及其以上版本包含)
currency_code : 当前国家货币代码    (每日旗舰版及其以上版本包含)
currency_name : 当前国家货币名称    (每日旗舰版及其以上版本包含)
anycast : ANYCAST       (每日旗舰版及其以上版本包含)
</pre>

### 适用于IPDB格式的中国地区 IPv4 区县库
  <pre>
import ipdb

db = ipdb.District("/path/to/china_district.ipdb")
print(db.is_ipv4(), db.is_ipv6())
print(db.languages())
print(db.fields())
print(db.build_time())
print(db.find("1.12.13.255", "CN"))
print(db.find_map("1.12.13.255", "CN"))
  </pre>

### 适用于IPDB格式的基站 IPv4 库
<pre>
import ipdb
db = ipdb.BaseStation("/path/to/base_station.ipdb")
print(db.is_ipv4(), db.is_ipv6())
print(db.languages())
print(db.fields())
print(db.build_time())
print(db.find_map("117.136.83.55", "CN"))
</pre>

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/magicbear/ipip-ipdb-hp",
    "name": "ipip-ipdb-hp",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "ipdb,ipip",
    "author": "MagicBear",
    "author_email": "magicbearmo@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f0/05/ae4261e25953ad245874d898591a0fffc631b604f2041fdae65db4c2f80b/ipip-ipdb-hp-0.1.1.tar.gz",
    "platform": null,
    "description": "# ipip-ipdb-hp\nHigh performance IPIP.net unofficially database ipdb format parsing library\n\n# Python Parse ipdb file\n\n## Installing\n```\npython3 setup.py build\npython3 setup.py install\n```\n\n## \u5b98\u65b9\u5e93\u6027\u80fd\u5bf9\u6bd4\n### C Version\n```\npython3 ipdotnet_benchmark.py\nLoad: 0.034990s  List Used: 0.2513652s  QPS: 397826/s\nLoad: 0.286393s  Dict Used: 0.2991660s  QPS: 334262/s\n```\n### Py Version\n```\nLoad: 0.074412s   List Used: 4.2106075s  QPS: 23750/s\nLoad: 4.285052s   Map  Used: 4.4340391s  QPS: 22553/s\n```\n\n## Code Example\n### \u9002\u7528\u4e8eIPDB\u683c\u5f0f\u7684\u6bcf\u5468\u9ad8\u7ea7\u7248\uff0c\u6bcf\u65e5\u6807\u51c6\u7248\uff0c\u6bcf\u65e5\u9ad8\u7ea7\u7248\uff0c\u6bcf\u65e5\u4e13\u4e1a\u7248\uff0c\u6bcf\u65e5\u65d7\u8230\u7248\n  <pre><code>\nimport ipdb\n\ndb = ipdb.City(\"/path/to/city.ipv4.ipdb\")\n# db.reload(\"/path/to/city.ipv4.ipdb\") # update ipdb database file reload data\nprint(db.is_ipv4(), db.is_ipv6())\nprint(db.languages()) # support language\nprint(db.fields()) #  support fields\nprint(db.build_time()) #  build database time\nprint(db.find(\"1.1.1.1\", \"CN\")) #  query ip return array\n# print(db.find(u\"1.1.1.1\", \"CN\")) #  Python 2.7\nprint(db.find_map(\"8.8.8.8\", \"CN\")) #  query ip return dict\nprint(db.find_info(\"118.28.1.1\", \"CN\").country_name) \n  </pre></code>\n\n### \u5730\u7ea7\u5e02\u7cbe\u5ea6\u5e93\u6570\u636e\u5b57\u6bb5\u8bf4\u660e\n<pre>\ncountry_name : \u56fd\u5bb6\u540d\u5b57 \uff08\u6bcf\u5468\u9ad8\u7ea7\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\nregion_name  : \u7701\u540d\u5b57   \uff08\u6bcf\u5468\u9ad8\u7ea7\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\ncity_name    : \u57ce\u5e02\u540d\u5b57 \uff08\u6bcf\u5468\u9ad8\u7ea7\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\nowner_domain : \u6240\u6709\u8005   \uff08\u6bcf\u5468\u9ad8\u7ea7\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\nisp_domain  : \u8fd0\u8425\u5546 \uff08\u6bcf\u5468\u9ad8\u7ea7\u7248\u4e0e\u6bcf\u65e5\u9ad8\u7ea7\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\nlatitude  :  \u7eac\u5ea6   \uff08\u6bcf\u65e5\u6807\u51c6\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\nlongitude : \u7ecf\u5ea6    \uff08\u6bcf\u65e5\u6807\u51c6\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\ntimezone : \u65f6\u533a     \uff08\u6bcf\u65e5\u6807\u51c6\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\nutc_offset : UTC\u65f6\u533a    \uff08\u6bcf\u65e5\u6807\u51c6\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\nchina_admin_code : \u4e2d\u56fd\u884c\u653f\u533a\u5212\u4ee3\u7801 \uff08\u6bcf\u65e5\u6807\u51c6\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\nidd_code : \u56fd\u5bb6\u7535\u8bdd\u53f7\u7801\u524d\u7f00 \uff08\u6bcf\u65e5\u6807\u51c6\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\ncountry_code : \u56fd\u5bb62\u4f4d\u4ee3\u7801  \uff08\u6bcf\u65e5\u6807\u51c6\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\ncontinent_code : \u5927\u6d32\u4ee3\u7801   \uff08\u6bcf\u65e5\u6807\u51c6\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\nidc : IDC |  VPN   \uff08\u6bcf\u65e5\u4e13\u4e1a\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\nbase_station : \u57fa\u7ad9 | WIFI \uff08\u6bcf\u65e5\u4e13\u4e1a\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\ncountry_code3 : \u56fd\u5bb63\u4f4d\u4ee3\u7801 \uff08\u6bcf\u65e5\u4e13\u4e1a\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\neuropean_union : \u662f\u5426\u4e3a\u6b27\u76df\u6210\u5458\u56fd\uff1a 1 | 0 \uff08\u6bcf\u65e5\u4e13\u4e1a\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\ncurrency_code : \u5f53\u524d\u56fd\u5bb6\u8d27\u5e01\u4ee3\u7801    \uff08\u6bcf\u65e5\u65d7\u8230\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\ncurrency_name : \u5f53\u524d\u56fd\u5bb6\u8d27\u5e01\u540d\u79f0    \uff08\u6bcf\u65e5\u65d7\u8230\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\nanycast : ANYCAST       \uff08\u6bcf\u65e5\u65d7\u8230\u7248\u53ca\u5176\u4ee5\u4e0a\u7248\u672c\u5305\u542b\uff09\n</pre>\n\n### \u9002\u7528\u4e8eIPDB\u683c\u5f0f\u7684\u4e2d\u56fd\u5730\u533a IPv4 \u533a\u53bf\u5e93\n  <pre>\nimport ipdb\n\ndb = ipdb.District(\"/path/to/china_district.ipdb\")\nprint(db.is_ipv4(), db.is_ipv6())\nprint(db.languages())\nprint(db.fields())\nprint(db.build_time())\nprint(db.find(\"1.12.13.255\", \"CN\"))\nprint(db.find_map(\"1.12.13.255\", \"CN\"))\n  </pre>\n\n### \u9002\u7528\u4e8eIPDB\u683c\u5f0f\u7684\u57fa\u7ad9 IPv4 \u5e93\n<pre>\nimport ipdb\ndb = ipdb.BaseStation(\"/path/to/base_station.ipdb\")\nprint(db.is_ipv4(), db.is_ipv6())\nprint(db.languages())\nprint(db.fields())\nprint(db.build_time())\nprint(db.find_map(\"117.136.83.55\", \"CN\"))\n</pre>\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "IPIP.net non-officially supported IP database ipdb format parsing library",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/magicbear/ipip-ipdb-hp"
    },
    "split_keywords": [
        "ipdb",
        "ipip"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f005ae4261e25953ad245874d898591a0fffc631b604f2041fdae65db4c2f80b",
                "md5": "68378e35bff7cd90f9fdc8ef7cd3a65e",
                "sha256": "0d99034448372c31ec7dc44c805dcffaeed7be3226d110bd7605a2cd9c563cd4"
            },
            "downloads": -1,
            "filename": "ipip-ipdb-hp-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "68378e35bff7cd90f9fdc8ef7cd3a65e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9033,
            "upload_time": "2024-02-27T13:42:22",
            "upload_time_iso_8601": "2024-02-27T13:42:22.815647Z",
            "url": "https://files.pythonhosted.org/packages/f0/05/ae4261e25953ad245874d898591a0fffc631b604f2041fdae65db4c2f80b/ipip-ipdb-hp-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-27 13:42:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "magicbear",
    "github_project": "ipip-ipdb-hp",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ipip-ipdb-hp"
}
        
Elapsed time: 0.31425s