Is there a way to save html text to a file in google drive using apps script?(有没有办法使用应用程序脚本将 html 文本保存到谷歌驱动器中的文件?)
问题描述
有没有办法使用应用程序脚本将 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 文本保存到谷歌驱动器中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:有没有办法使用应用程序脚本将 html 文本保存到


- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01