我有這個簡單的腳本來獲得一個頁面並且不改變地輸出它。但是,瀏覽器無法將輸出識別爲HTML,並將其顯示爲文本。如何從Google Apps腳本輸出HTML?
function doGet(e) {
var url = e.queryString || "";
if (url != "") {
return getPage(url);
}
return "not found";
}
function test() {
return getPage("www.google.com");
}
function getPage(url) {
var options = {
headers : {'Cache-Control' : 'max-age=0'}
};
var response = UrlFetchApp.fetch(url, options);
var html = response.getContent();
return ContentService.createTextOutput(html).setMimeType(ContentService.MimeType.HTML);
}
怎麼了?我怎樣才能將提取的頁面輸出爲HTML?
嗯,HTML不在有效的MIME類型列表中:https://developers.google.com/apps-script/reference/content/mime-type – Paul 2014-11-05 05:02:54
我真的不知道,但看看這裏: https://developers.google.com/apps-script/reference/html/html-output – Paul 2014-11-05 05:05:18