This is a sample script for retrieving All URLs in Google Document using Google Apps Script. In this sample script, the method of “documents.get” in Google Docs API is used. By this, the URL can be retrieve using JSON.parse()
.
Sample script
Before you use this script, please enable Google Docs API at Advanced Google Services.
const documentId = "###"; // Please set the Google Document ID.
const content = Docs.Documents.get(documentId).body.content;
const urls = [];
JSON.parse(JSON.stringify(content), (k, v) => {
if (k == "url") urls.push(v);
});
console.log(urls);