0

I am trying to download html and save it to a local file using Google Apps Script.

Here is the code:

function save_url(url, filename) {
  var html = UrlFetchApp.fetch(url).getContentText();

  // None of the following work.
  DocsList.createFile(fileName, html);
  jobFolder.createFile(filename, html, MimeType.PLAIN_TEXT);
  DriveApp.createFile(filename, html);

  return txt;

}

But it doesn't work. Is there a way to do this?

ChaimG
  • 7,024
  • 4
  • 38
  • 46
  • Could you kindly provide the precise error you are encountering? Additionally, please note that the `DocsList` class appears to be deprecated. When tested in the Google Apps Script editor, it results in the error message: `ReferenceError: DocsList is not defined`. Lastly, for the sake of clarity, is your primary objective to download the HTML and store it in your Google Drive, or are you aiming to save it as a local file on your computer? – SputnikDrunk2 Aug 23 '23 at 19:21
  • `jobFolder` and `txt` are both undefined – Cooper Aug 23 '23 at 19:43
  • Why don't you just download the html file with GDrive and be done with it? – Cooper Aug 23 '23 at 19:50
  • Try [Dr-Brackets solution](https://stackoverflow.com/a/69548483/7215091) – Cooper Aug 23 '23 at 20:22

0 Answers0