簡體   English   中英

有沒有辦法使用應用程序腳本將html文本保存到谷歌驅動器中的文件?

[英]Is there a way to save html text to a file in google drive using apps script?

有沒有辦法使用應用程序腳本將html文本保存到谷歌驅動器中的文件? 我的應用程序發回一個html字符串,我想將其作為.html文件保存到驅動器中,就像我上傳了一個HTML文件來驅動。 然后我打算打開這個.html文件作為谷歌文檔,將其轉換為doc格式。 我手動嘗試了這個程序,效果很好。 只需要在腳本中執行它。

更重要的是,我喜歡將HTML轉換為谷歌文檔的直接方式。

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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM