我正在尝试使用UrlFetchApp.fetch记录网址的网页来源,但无法记录完整内容。字符串在大约8KB的文本后被切断。
我正在使用谷歌应用程序脚本来记录一些Instagram帐户的关注者数量。它的工作原理是从页面源中分割出跟随者计数。在工作了几个星期之后,它在两天前的12月12日突然停止工作。
当我记录内容文本时,我发现问题是只记录了部分页面源。该脚本现在已经失效,因为跟随者计数比页面源中记录的内容更低。
如何将整页源代码转换为字符串?使用UrlFetchApp.fetch可以获得什么限制?
function test(){
var options = {
'method' : 'post'
};
//I get the same issue whether or not I include the options variable to make it a POST request.
var instaPage = UrlFetchApp.fetch("https://www.instagram.com/barackobama", options).getContentText();
Logger.log(instaPage);
}
答案 0 :(得分:0)
方法Logger.log
修剪输出字符串,而不是UrlFetchApp.fetch
。如果您想查看整个变量instaPage
,可以快速将其放在电子表格单元格中:
SpreadsheetApp.getActiveSheet.getRange("A1").setValue(instaPage);