如何使用 Cheerio on GAS 在 Html 页面上获取特定信息?
How to get a specific info on an Html page, using Cheerio on GAS?
我无法确定代码应该从中获取信息的任何 class、id 等。
这是 html 页面和我应该每天获取的信息:
...这是我尝试使用的代码片段:
var content = UrlFetchApp.fetch("https://ovoonline.com.br/", options).getContentText();
const $ = Cheerio.load(content);
Logger.log($('td[colspan="2"]').text());
这是它的选择器,但它没有输出正确的结果:
body > table > tbody > tr > td > table > tbody > tr > td:nth-child(2) > table:nth-child(2) > tbody > tr:nth-child(6) > td > table > tbody > tr:nth-child(2) > td:nth-child(2) > table > tbody > tr:nth-child(1) > td:nth-child(1) > table > tbody > tr:nth-child(18) > td > table > tbody > tr:nth-child(2) > td:nth-child(2) > table > tbody > tr > td:nth-child(1)
谢谢!
这对我有用:
var content = UrlFetchApp.fetch("https://ovoonline.com.br/",options)
.getContentText();
const $ = Cheerio.load(content);
Logger.log($('td[width="45"]').eq(1).text());
结果日志:
我无法确定代码应该从中获取信息的任何 class、id 等。
这是 html 页面和我应该每天获取的信息:
...这是我尝试使用的代码片段:
var content = UrlFetchApp.fetch("https://ovoonline.com.br/", options).getContentText();
const $ = Cheerio.load(content);
Logger.log($('td[colspan="2"]').text());
这是它的选择器,但它没有输出正确的结果:
body > table > tbody > tr > td > table > tbody > tr > td:nth-child(2) > table:nth-child(2) > tbody > tr:nth-child(6) > td > table > tbody > tr:nth-child(2) > td:nth-child(2) > table > tbody > tr:nth-child(1) > td:nth-child(1) > table > tbody > tr:nth-child(18) > td > table > tbody > tr:nth-child(2) > td:nth-child(2) > table > tbody > tr > td:nth-child(1)
谢谢!
这对我有用:
var content = UrlFetchApp.fetch("https://ovoonline.com.br/",options)
.getContentText();
const $ = Cheerio.load(content);
Logger.log($('td[width="45"]').eq(1).text());
结果日志: