@ali1416/ip2region
v1.2.0
Published
IP地址转区域JavaScript版
Downloads
14
Readme
IP Address To Region For JavaScript IP地址转区域JavaScript版
简介
本项目迁移自ALI1416/ip2region,构建后ip2region.min.js
文件仅3kb
数据文件
- 数据文件目录:点击查看
其他语言项目
Java
: ALI1416/ip2region
依赖导入
网页
https://unpkg.com/@zip.js/zip.js/dist/zip.min.js https://unpkg.com/@ali1416/ip2region/dist/ip2region.min.js
node
npm install @ali1416/ip2region
使用示例
// node test-node.js
const fs = require('fs')
const {Ip2Region} = require('../dist/ip2region.node')
let url = 'https://www.404z.cn/files/ip2region/v3.0.0/data/ip2region.zdb'
let zdbPath = 'D:/ip2region.zdb'
let ip2Region = new Ip2Region()
// runUrl()
runFile()
async function runUrl() {
await ip2Region.initByUrl(url)
run()
}
async function runFile() {
let buffer = fs.readFileSync(zdbPath).buffer
await ip2Region.init(buffer)
run()
}
function run() {
console.log(ip2Region.parse('0.0.0.0'))
console.log(ip2Region.parse('123.132.0.0'))
}
更多请见测试