問題描述
有沒有辦法使用應用程序腳本將 html 文本保存到谷歌驅動器中的文件?我的應用程序發回一個 html 字符串,我想將其作為 .html 文件保存到驅動器中,就像我將 HTML 文件上傳到驅動器一樣.然后,我打算將此 .html 文件作為 google doc 打開,這會將其轉換為 doc 格式.我已經手動嘗試過這個過程,效果很好.只需要在腳本中完成.
Is there a way to save html text to a file in google drive using apps script? My app sends back an html string, which I want to save as an .html file into drive, as if I'd uploaded an HTML file to drive. I then intend on opening this .html file as a google doc, which will convert it to a doc format. I've tried this procedure manually, and it works well. Just need to do it in a script.
更重要的是,我想要一種直接將 HTML 轉換為谷歌文檔的方法.
More to the point, I'd love a direct way to convert HTML into a google doc.
推薦答案
var url = 'YOUR PAGE;
var p = SitesApp.getPageByUrl(url);
var html = p.getHtmlContent();
var blob = DriveApp.createFile('dummy',html, 'text/html').getBlob();
var resource = {
title: 'YOUR FILE NAME',
convert: true,
mimeType: 'application/vnd.google-apps.document'
};
Drive.Files.insert(resource,blob);
這篇關于有沒有辦法使用應用程序腳本將 html 文本保存到谷歌驅動器中的文件?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!