0
使用Google Apps腳本我如何打任何URL?使用Google Apps腳本我如何打任何網址?
在實例中,我想要這樣的代碼在應用程序腳本中工作相同的Java代碼工作,我已經提供了下面。
URL url = new URL("http://google.com");
URLConnection conn = url.openConnection();
conn.connect();
使用Google Apps腳本我如何打任何URL?使用Google Apps腳本我如何打任何網址?
在實例中,我想要這樣的代碼在應用程序腳本中工作相同的Java代碼工作,我已經提供了下面。
URL url = new URL("http://google.com");
URLConnection conn = url.openConnection();
conn.connect();
您應該使用URL Fetch服務來連接到URL。
try {
var response = UrlFetchApp.fetch("http://www.google.com/");
Logger.log(response.getResponseCode());
Logger.log(response.getContentText());
} catch (e) {
Logger.log(e.toString());
}
非常感謝!它的工作現在很好。 – 2014-09-15 01:52:36