简体   繁体   English

有没有办法使用应用程序脚本将html文本保存到谷歌驱动器中的文件?

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

Is there a way to save html text to a file in google drive using apps script? 有没有办法使用应用程序脚本将html文本保存到谷歌驱动器中的文件? 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. 我的应用程序发回一个html字符串,我想将其作为.html文件保存到驱动器中,就像我上传了一个HTML文件来驱动。 I then intend on opening this .html file as a google doc, which will convert it to a doc format. 然后我打算打开这个.html文件作为谷歌文档,将其转换为doc格式。 I've tried this procedure manually, and it works well. 我手动尝试了这个程序,效果很好。 Just need to do it in a script. 只需要在脚本中执行它。

More to the point, I'd love a direct way to convert HTML into a google 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.

相关问题 如何将Google云端硬盘文件选择器与Apps脚本HTML服务一起使用 - How to use Google Drive File Picker with Apps Script HTML Service 使用 Google Apps 脚本将文件上传到 Google Drive - Upload File To Google Drive Using Google Apps Script 使用 HTML 和谷歌应用程序脚本突出显示谷歌表格单元格中的文本 - Highlighting text in a google sheet cell using HTML and google apps script HTML 从 Google 表格到 Google Apps 脚本上的 Google Drive 的图像 - HTML to Image from Google Sheets to Google Drive on Google Apps Script 如何使用 Google Apps Script 在 UI 弹出窗口中生成 html 文本? - How to produce html text in UI popup using Google Apps Script? 使用 Google Apps Scripts 将 Google Drive 图像插入到模板化的 html 中 - Inserting Google Drive image into templated html using Google Apps Scripts 如何为文件上传添加状态栏? (谷歌驱动器/应用程序脚本) - How to add a status bar for file upload? (Google Drive/ Apps Script) Google Apps脚本WebApp将html传递到文件 - Google Apps Script WebApp Pass html to file HTML 表单文件上传到 Google Drive 并将 URL 保存到 google sheet - HTML form file upload to Google Drive and save URL to google sheet 如何使用 Google Apps Script 从 .gs 将 HTML 代码插入到 HTML 文件中 - How to insert HTML code into HTML file from a .gs using Google Apps Script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM