Is there a way to save the html text to a file in Google Drive using script applications?

Is there a way to save the html text to a file in Google Drive using script applications? My application sends back the html string that I want to save as an .html file on disk, as if I had downloaded the HTML file to disk. Then I intend to open this .html file as a google document that will convert it to a document format. I tried this procedure manually and it works well. Just need to do this in a script.

More, I would like a direct way to convert HTML to google document.

+4
source share
1 answer
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);
+2

Source: https://habr.com/ru/post/1530507/


All Articles