有没有办法使用应用程序脚本将HTML文本保存到谷歌驱动器中的文件? [英] Is there a way to save html text to a file in google drive using apps script?

查看:73
本文介绍了有没有办法使用应用程序脚本将HTML文本保存到谷歌驱动器中的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以将html文本保存到使用apps脚本的谷歌驱动器中的文件中?我的应用程序发回一个html字符串,我想将其保存为一个.html文件到驱动器,就像我上传一个HTML文件驱动器一样。然后,我打算将这个.html文件作为Google文档打开,并将其转换为文档格式。我已经手动尝试了这个程序,并且运行良好。只需要在脚本中完成即可。



更重要的是,我喜欢将HTML转换为Google文档的直接方式。

解决方案

var url ='您的页面;
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);


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.

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文本保存到谷歌驱动器中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆