Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to get a website's IP using Apps Script

I have looked at the UrlFetchApp documentation and I have searched the internet for a solution, but I don't see any way to retrieve the IP of a target URL in Apps Script. Is there a way to do this?

Thanks

like image 985
michaeldon Avatar asked Mar 05 '23 12:03

michaeldon


1 Answers

You can do this using dns.google.com

function lookup(){
   var lookup = JSON.parse(UrlFetchApp.fetch("https://dns.google.com/resolve?name=wikipedia.com&type=A"));
}

The IP is in the response.

like image 194
James D Avatar answered Mar 27 '23 07:03

James D