首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Haskell查询IP2Location LITE二进制数据库?

使用Haskell查询IP2Location LITE二进制数据库?
EN

Stack Overflow用户
提问于 2015-05-15 11:27:04
回答 2查看 113关注 0票数 0

我想使用Haskell从here查询IP2Location LITE二进制数据库。所以我想知道是否有任何现有的模块或代码来读取数据库?

EN

回答 2

Stack Overflow用户

发布于 2015-05-16 23:21:09

我不知道ip2location,但是有一个geoip2原生模块可以和Geoip2数据库一起工作。根据你想用它来做什么,它可能对你有用。

票数 1
EN

Stack Overflow用户

发布于 2016-10-17 10:23:15

您可以使用Github中的以下示例代码

代码语言:javascript
复制
import IP2Location

main :: IO ()
main = do
    let myfile = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE.BIN"
    meta <- doInit myfile
    result <- doQuery myfile meta "8.8.8.8"
    putStrLn $ "country_short: " ++ (show (country_short result))
    putStrLn $ "country_long: " ++ (show (country_long result))
    putStrLn $ "region: " ++ (show (region result))
    putStrLn $ "city: " ++ (show (city result))
    putStrLn $ "isp: " ++ (show (isp result))
    putStrLn $ "latitude: " ++ (show (latitude result))
    putStrLn $ "longitude: " ++ (show (longitude result))
    putStrLn $ "domain: " ++ (show (domain result))
    putStrLn $ "zipcode: " ++ (show (zipcode result))
    putStrLn $ "timezone: " ++ (show (timezone result))
    putStrLn $ "netspeed: " ++ (show (netspeed result))
    putStrLn $ "iddcode: " ++ (show (iddcode result))
    putStrLn $ "areacode: " ++ (show (areacode result))
    putStrLn $ "weatherstationcode: " ++ (show (weatherstationcode result))
    putStrLn $ "weatherstationname: " ++ (show (weatherstationname result))
    putStrLn $ "mcc: " ++ (show (mcc result))
    putStrLn $ "mnc: " ++ (show (mnc result))
    putStrLn $ "mobilebrand: " ++ (show (mobilebrand result))
    putStrLn $ "elevation: " ++ (show (elevation result))
    putStrLn $ "usagetype: " ++ (show (usagetype result))

您需要使用cabal安装IP2Location包:

代码语言:javascript
复制
cabal install IP2Location

黑客攻击页面:https://hackage.haskell.org/package/ip2location-8.0.4/docs/IP2Location.html

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30251045

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档