I would like to know if there is a formula/script one could use on Google Spreadsheet to obtain the City,Location of an array of IP addresses.
我想知道是否有可以在Google电子表格上使用的公式/脚本来获取城市,IP地址数组的位置。
i.e lets imagine that each cell on column A has 100 IP addresses, what formula/script should I use on column B to get the respective city and location?
即让我们想象A列上的每个单元都有100个IP地址,我应该在B列使用什么公式/脚本来获取相应的城市和位置?
2 个解决方案
#1
4
After some digging I've figured out how to do this.
经过一番挖掘后,我发现了如何做到这一点。
-
Copy the
import_json_appsscript.js
script on https://gist.github.com/chrislkeller/5719258. This will be the script that will create theImportJSON()
function to a Google spreadsheet复制https://gist.github.com/chrislkeller/5719258上的import_json_appsscript.js脚本。这将是为Google电子表格创建ImportJSON()函数的脚本
-
Go to Google spreadsheet, on the menu bar got to Tools > Script Editor
转到Google电子表格,在菜单栏上找到工具>脚本编辑器
-
Copy paste
import_json_appsscript.js
into the Script Editor and save it, Double check that you can see theImportJSON()
function on the Select function drop down menu.将import_json_appsscript.js粘贴到脚本编辑器中并保存,请仔细检查您是否可以在Select function下拉菜单中看到ImportJSON()函数。
-
On the Spreadsheet use function =ImportJSON(url, query, options), for example
=ImportJSON("http://freegeoip.net/json/75.148.30.137", "/city", "noHeaders")
to retrieveBaltimore
from the FreeGeoIP call.在电子表格上使用function = ImportJSON(url,query,options),例如= ImportJSON(“http://freegeoip.net/json/75.148.30.137”,“/ city”,“noHeaders”)从中检索巴尔的摩FreeGeoIP电话。
Hope that helps, it certainly answers my question.
希望有所帮助,它肯定回答了我的问题。
#2
1
If you are looking to write a macro of some sort, you could consider using freegeoip.net which lets you make a simple restful call to get back data in a variety of formats.
如果您正在寻找某种类型的宏,您可以考虑使用freegeoip.net,它允许您进行简单的休息调用以获取各种格式的数据。
For example, a call to find the location for the ip address 75.148.30.137 would look like this:
例如,查找IP地址75.148.30.137的位置的调用如下所示:
http://freegeoip.net/json/75.148.30.137
Also, here is a link to Google's documentation on how to make rest calls in a Google app:
此外,还有一个指向Google文档的链接,该文档介绍了如何在Google应用中进行休息通话:
https://developers.google.com/apps-script/guides/services/external
Good luck.
#1
4
After some digging I've figured out how to do this.
经过一番挖掘后,我发现了如何做到这一点。
-
Copy the
import_json_appsscript.js
script on https://gist.github.com/chrislkeller/5719258. This will be the script that will create theImportJSON()
function to a Google spreadsheet复制https://gist.github.com/chrislkeller/5719258上的import_json_appsscript.js脚本。这将是为Google电子表格创建ImportJSON()函数的脚本
-
Go to Google spreadsheet, on the menu bar got to Tools > Script Editor
转到Google电子表格,在菜单栏上找到工具>脚本编辑器
-
Copy paste
import_json_appsscript.js
into the Script Editor and save it, Double check that you can see theImportJSON()
function on the Select function drop down menu.将import_json_appsscript.js粘贴到脚本编辑器中并保存,请仔细检查您是否可以在Select function下拉菜单中看到ImportJSON()函数。
-
On the Spreadsheet use function =ImportJSON(url, query, options), for example
=ImportJSON("http://freegeoip.net/json/75.148.30.137", "/city", "noHeaders")
to retrieveBaltimore
from the FreeGeoIP call.在电子表格上使用function = ImportJSON(url,query,options),例如= ImportJSON(“http://freegeoip.net/json/75.148.30.137”,“/ city”,“noHeaders”)从中检索巴尔的摩FreeGeoIP电话。
Hope that helps, it certainly answers my question.
希望有所帮助,它肯定回答了我的问题。
#2
1
If you are looking to write a macro of some sort, you could consider using freegeoip.net which lets you make a simple restful call to get back data in a variety of formats.
如果您正在寻找某种类型的宏,您可以考虑使用freegeoip.net,它允许您进行简单的休息调用以获取各种格式的数据。
For example, a call to find the location for the ip address 75.148.30.137 would look like this:
例如,查找IP地址75.148.30.137的位置的调用如下所示:
http://freegeoip.net/json/75.148.30.137
Also, here is a link to Google's documentation on how to make rest calls in a Google app:
此外,还有一个指向Google文档的链接,该文档介绍了如何在Google应用中进行休息通话:
https://developers.google.com/apps-script/guides/services/external
Good luck.