{"id":16217288,"url":"https://github.com/synodriver/pyip2region","last_synced_at":"2025-10-28T00:38:59.913Z","repository":{"id":100676377,"uuid":"554535290","full_name":"synodriver/pyip2region","owner":"synodriver","description":"python binding for ip2region","archived":false,"fork":false,"pushed_at":"2025-09-23T15:43:32.000Z","size":287,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-23T17:36:49.458Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Cython","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/synodriver.png","metadata":{"files":{"readme":"README.markdown","changelog":"changename.py","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-20T01:12:07.000Z","updated_at":"2025-09-23T15:43:36.000Z","dependencies_parsed_at":"2023-05-16T18:30:51.087Z","dependency_job_id":null,"html_url":"https://github.com/synodriver/pyip2region","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/synodriver/pyip2region","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synodriver%2Fpyip2region","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synodriver%2Fpyip2region/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synodriver%2Fpyip2region/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synodriver%2Fpyip2region/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/synodriver","download_url":"https://codeload.github.com/synodriver/pyip2region/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synodriver%2Fpyip2region/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281366885,"owners_count":26488696,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-27T02:00:05.855Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T11:26:28.096Z","updated_at":"2025-10-28T00:38:59.909Z","avatar_url":"https://github.com/synodriver.png","language":"Cython","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\u003ci\u003e✨ pyip2region ✨ \u003c/i\u003e\u003c/h1\u003e\n\n\u003ch3 align=\"center\"\u003eThe python binding for \u003ca href=\"https://github.com/lionsoul2014/ip2region\"\u003eip2region\u003c/a\u003e \u003c/h3\u003e\n\n\n[![pypi](https://img.shields.io/pypi/v/ip2region.svg)](https://pypi.org/project/ip2region/)\n![python](https://img.shields.io/pypi/pyversions/ip2region)\n![implementation](https://img.shields.io/pypi/implementation/ip2region)\n![wheel](https://img.shields.io/pypi/wheel/ip2region)\n![license](https://img.shields.io/github/license/synodriver/pyip2region.svg)\n![action](https://img.shields.io/github/workflow/status/synodriver/pyip2region/build%20wheel)\n\n\n### 使用方式\n\n### 完全基于文件的查询\n\n```python\nfrom ip2region import Searcher, VectorIndex, Header, Version\nheader = Header.from_file(r\".\\ip2region_v6.xdb\")\nversion = Version.from_header(header)\n# 备注：并发使用，每一个线程需要单独定义并且初始化一个 searcher 查询对象，或者加锁\nsearcher = Searcher.from_file(version, r\"E:\\pyproject\\pyip2region\\tests\\ip2region_v6.xdb\")\nresult = searcher.search_by_string(\"2001:0:2851:b9f0:3866:13a2:846f:c23b\")\nprint(result)\n```\n\n### 缓存 `VectorIndex` 索引\n```python\nfrom ip2region import Searcher, VectorIndex, Header, Version\nheader = Header.from_file(r\".\\ip2region_v4.xdb\")\nversion = Version.from_header(header)\nindex = VectorIndex.from_file(r\".\\ip2region_v4.xdb\")\nsearcher = Searcher.from_index(version, r\".\\ip2region_v4.xdb\", index)\nresult = searcher.search_by_string(\"1.1.1.1\")\nprint(result)\n```\n\n### 缓存整个 `xdb` 数据\n\n```python\nfrom ip2region import Searcher, VectorIndex, Header, Version\n\nheader = Header.from_file(r\".\\ip2region_v4.xdb\")\nversion = Version.from_header(header)\nwith open(r\".\\ip2region_v4.xdb\", \"rb\") as f:\n    data = f.read()\nsearcher = Searcher.from_buffer(version, data)\nresult = searcher.search_by_string(\"1.1.1.1\")\nprint(result)\n```\n\n### 注意：\n多线程模式下，只有纯内存的才是线程安全的，其他都需要用户自己加锁加锁，程序中没有任何机制保证线程安全","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynodriver%2Fpyip2region","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsynodriver%2Fpyip2region","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynodriver%2Fpyip2region/lists"}