我使用cheeriogs库在谷歌应用程序脚本中工作:
脚本ID:1ReeQ6WO8kKNxoaA_O0XEQ589cIrRvEBA9qcWpNqdOP17i47u6N9M5Xh0
https://github.com/tani/cheeriogs
我当前尝试使用的代码不包含如下内容:
function myFunction() {
var sheet = SpreadsheetApp.getActive().getSheetByName('Seu Seriado');
var url = 'https://seuseriado.org/';
const contentText = UrlFetchApp.fetch(url).getContentText();
const $ = Cheerio.load(contentText);
$('h2.entry-title.h6 > a:not(contains("SEM LEGENDA"))')
.each((index, element) => {sheet.getRange(index+1,1).setValue($(element).text().trim());});
}
但给出了一个错误:
SyntaxError: missing closing parenthesis in :not ("SEM LEGENDA"))
考虑到没有括号缺失,并且for not的模型中包含一些cheerio用户所指出的正是添加括号的等号,我应该怎么做才能解决这个问题?
您需要:before contains,因为它是一个伪,所以它是
a:not(:contains(text))