我想使用Haskell从here查询IP2Location LITE二进制数据库。所以我想知道是否有任何现有的模块或代码来读取数据库?
发布于 2015-05-16 23:21:09
我不知道ip2location,但是有一个geoip2原生模块可以和Geoip2数据库一起工作。根据你想用它来做什么,它可能对你有用。
发布于 2016-10-17 10:23:15
您可以使用Github中的以下示例代码
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包:
cabal install IP2Location黑客攻击页面:https://hackage.haskell.org/package/ip2location-8.0.4/docs/IP2Location.html
https://stackoverflow.com/questions/30251045
复制相似问题