使用Google App脚本解析HTML元素中的值? [英] Parse values from HTML element using Google App Script?

查看:139
本文介绍了使用Google App脚本解析HTML元素中的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Google协作平台上按类解析HTML元素,我的代码是:

I am trying to parse HTML element by class on Google Sites, my code is:

function doGet(){

  var html = UrlFetchApp.fetch ('http://indicadoresdeldia.cl/').getContentText();
  var doc = XmlService.parse(html);
  var html = doc.getRootElement();
  var menu = getElementsByClassName(html, 'span3 utm')[0];
  var output = XmlService.getRawFormat().format(menu);
  return HtmlService.createHtmlOutput(output);

}

我在运行代码时出现了nexte错误消息ReferenceError:未定义"getElementsByClassName".

Ween i run the code appear the nexte error message ReferenceError: "getElementsByClassName" is not defined.

我正在尝试为下一页部署示例:https://sites.google.com/site/scriptsexamples/learn-by-example/parsing-html

i am trying to deploy the example for the next page: https://sites.google.com/site/scriptsexamples/learn-by-example/parsing-html

有什么想法吗?

提前感谢您的帮助.

推荐答案

根据该站点,您应该将这些函数直接复制到您的项目(可从此处获得源代码)中,然后再调用它们.这将减轻您的每一个问题.

According to that site, you should directly copy those functions to your project (source code available there) and then call them. That would alleviate each and every one of your problems.

这篇关于使用Google App脚本解析HTML元素中的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆