我正在尝试从Zacks.com网站的参数中获取"rank_view“类的值。下面是我写的脚本:
function ZacksRank (url) {
//url.toString().trim();
// Get the content of that site as a string
var d = UrlFetchApp.fetch(url).getContentText();
// String to search (in your case following the class value)
// Note that the string to be search contains 19 characters
var search = 'class="rank_view">';
// Get the index where the data we are interested is found in the string
var index = d.search(search);
// Get the character at that index (plus 19 is because search returns the
// index of the first character of the search, in this case it would return
// the index of c (of class) and therefore we must add to the index the length
// of our string
var value = d.charAt(index+search.length);
return(value);
}
我像这样调用函数:
=zacksrank("http://www.zacks.com/stock/quote/abbv")
但我得到了以下错误消息:
Exception: Address unavailable: http://www.zacks.com/stock/quote/abbv
有人能帮上忙吗?非常感谢:) Gabriel
发布于 2020-07-15 17:43:25
此错误意味着您正在尝试获取的页面当前不可用。你的脚本没有问题。"zacks.com“网站完全没有响应。
为了证明这一点,你可以使用一个你确信它会工作的网页的网址,例如"https://www.google.com"“。
https://stackoverflow.com/questions/62905227
复制相似问题