A javascript library for searching IP data in CZIP'S qqwry.dat file
npm install lim-qqwryqqwry.dat, which can perform isp query and convert .dat files into json files, which can be directly imported into MongoDB, etc.
npm install lim-qqwry
`
Example
`javascript
import LimQqwry from "lim-qqwry";
import path from "path";
import fs from "fs";
const datapath = path.join(__dirname, "./qqwry.dat");
const qqwry = new LimQqwry(datapath);
// query ip information
const ipdata = qqwry.searchIP("115.120.105.66");
console.log(ipdata);
// convert to json
const result = qqwry.toJson(datapath);
fs.writeFile("./data.json", JSON.stringify(result), () => {
console.log("succeed!");
});
`
$3
Other
$3
`javascript
let startIpIntList = null;
async function queryIpInfo(ip) {
if (!startIpIntList) {
startIpIntList = new LimQqwry(
path.join(process.cwd(), "data/qqwry.dat")
).getStartIpIntList();
}
const ipInt = LimQqwry.ipToInt(ip);
const queryIp = LimQqwry.getStartIpInt(ipInt, startIpIntList);
const data = await Mapper.getIpData(queryIp); // database query code example
return { ip, country: data.country, isp: data.isp };
}
``