之前介紹了使用 Cloudflare worker來進行客戶端 IP調查的小程式(https://diary.tw/archives/2182), 最近新增一些功能上來.
- 利用瀏覽器訪問時, 會加上完整的 html, 並增加了 Google Analytics 追蹤碼, 來記錄使用的次數.
- 若是利用非瀏覽器訪問時, 會直接輸出純文字 ip 而不會加上其他的內容, 例如: curl https://ip.diary.tw/
- 利用這個 geoplugin 這個免費的 API 功能來查找對應 IP的資訊, 請參考這個 API文件說明: https://www.geoplugin.com/webservices/json, 使用方式為 https://ip.diary.tw/?data=geo, 可以查找對應 IP的所在地與該地區使用貨幣與匯率. 輸出範例如下:
{
"geoplugin_request":"12.34.56.78",
"geoplugin_status":200,
"geoplugin_delay":"1ms",
"geoplugin_credit":"Some of the returned data includes GeoLite2 data created by MaxMind, available from <a href='https:\/\/www.maxmind.com'>https:\/\/www.maxmind.com<\/a>.",
"geoplugin_city":"New Taipei City",
"geoplugin_region":"New Taipei City",
"geoplugin_regionCode":"NWT",
"geoplugin_regionName":"New Taipei City",
"geoplugin_areaCode":"",
"geoplugin_dmaCode":"",
"geoplugin_countryCode":"TW",
"geoplugin_countryName":"Taiwan",
"geoplugin_inEU":0,
"geoplugin_euVATrate":false,
"geoplugin_continentCode":"AS",
"geoplugin_continentName":"Asia",
"geoplugin_latitude":"24.9466",
"geoplugin_longitude":"121.586",
"geoplugin_locationAccuracyRadius":"20",
"geoplugin_timezone":"Asia\/Taipei",
"geoplugin_currencyCode":"TWD",
"geoplugin_currencySymbol":"NT$",
"geoplugin_currencySymbol_UTF8":"NT$",
"geoplugin_currencyConverter":32.0408
}
請大家多加利用 IP查找小功具: https://ip.diary.tw