[英]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.