首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >例外:地址不可用的Google脚本

例外:地址不可用的Google脚本
EN

Stack Overflow用户
提问于 2020-07-15 07:01:29
回答 1查看 1.4K关注 0票数 0

我正在尝试从Zacks.com网站的参数中获取"rank_view“类的值。下面是我写的脚本:

代码语言:javascript
运行
复制
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);
  
}

我像这样调用函数:

代码语言:javascript
运行
复制
=zacksrank("http://www.zacks.com/stock/quote/abbv")

但我得到了以下错误消息:

代码语言:javascript
运行
复制
Exception: Address unavailable: http://www.zacks.com/stock/quote/abbv

有人能帮上忙吗?非常感谢:) Gabriel

EN

Stack Overflow用户

发布于 2020-07-15 17:43:25

此错误意味着您正在尝试获取的页面当前不可用。你的脚本没有问题。"zacks.com“网站完全没有响应。

为了证明这一点,你可以使用一个你确信它会工作的网页的网址,例如"https://www.google.com"“。

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62905227

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档