0
我需要定期保存从给定网站到google doc文件的所有链接。我花了几个小时试图做到这一点,但我是一个初学者,没有为我工作。我将不胜感激任何建议。Google Apps脚本 - 如何保存从网站到Google文档文件的所有链接?
这里是我的尝试之一(但它可能是更好地忽略它,因为它没有工作,反正):
function save_links() {
// create a google doc file named 'links'
var doc = DocumentApp.create('links');
// save the source code of the website in question to a string
var str = UrlFetchApp.fetch('https://www.the_website_in_question').getContentText();
// find all links
var link = str.findText('https:\/\/.*\/');
// save every link to the google doc file
while (link != null) {
var foundLink = link.getElement().asText();
doc.getBody().appendParagraph(foundLink);
link = link.findText('http:\/\/.*\/', link);
}
}
非常感谢你!我不明白你的消息,但你的源代码就像一个魅力! – Jane
学习javascript是消息:) –