Created
May 1, 2020 20:24
-
-
Save erajanraja24/9afd460c3277738b74ee0bf917a5b591 to your computer and use it in GitHub Desktop.
Save Webpage as Google Doc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sh1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1"); | |
function take_back_up(){ | |
var lrow = sh1.getLastRow(); | |
for(var i=2;i<=lrow;i++){ | |
var url = save_as_doc(sh1.getRange(i, 1).getValue()) | |
Logger.log(url) | |
sh1.getRange(i, 2).setValue(url) | |
} | |
} | |
function save_as_doc(url) { | |
//var url = "https://www.wpbeginner.com/wp-tutorials/how-to-teach-online-yoga-classes-with-wordpress/"; // <--- Please set URL that you want to retrieve table. | |
var html = UrlFetchApp.fetch(url); | |
var folderid = '1IxMiswEfi67ovoBf8ZH1RV7qVPx1Ks6l'; | |
var formattedDate = Utilities.formatDate(new Date(), "GMT", "MM-dd-yyyy HH:mm:ss"); | |
var docId = Drive.Files.insert( | |
{ title: "Doc "+formattedDate, | |
parents: [{id:'1IxMiswEfi67ovoBf8ZH1RV7qVPx1Ks6l'}], | |
mimeType: MimeType.GOOGLE_DOCS }, | |
html.getBlob() | |
).id; | |
var file = DriveApp.getFileById(docId) | |
var fileUrl = file.getUrl(); | |
Logger.log(fileUrl) | |
return fileUrl; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment