我有一个关于调用的结构部分的问题,对UrlFetchApp
的每日调用限制为1,000,在我的示例代码中使用的模型中,使用了多少UrlFetchApp
调用?
只有一个和从它是工作在每四个var
线下面还是四个UrlFetchApp
调用需要?
文档:https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app
为CherrioGS添加信息、文档:
https://github.com/tani/cheeriogs
function PaginaDoJogo() {
var sheet = SpreadsheetApp.getActive().getSheetByName('Dados Importados');
var url = sheet.getRange('Dados Importados!A1').getValue();
const contentText = UrlFetchApp.fetch(url).getContentText();
const $ = Cheerio.load(contentText);
var Regiao = $('#page_match_1_block_competition_left_tree_2-wrapper > div.header-wrapper > h2.header-label');
sheet.getRange(2, 17).setValue(Regiao.text().trim());
var Competicao = $('#page_match_1_block_match_info_5 > div > div > div.details > a:nth-child(3)');
sheet.getRange(3, 17).setValue(Competicao.text().trim());
var NomeTimeA = $('#page_match_1_block_match_info_5 > div > div > div.container.left > a.team-title');
sheet.getRange(2, 10).setValue(NomeTimeA.text());
var NomeTimeB = $('#page_match_1_block_match_info_5 > div > div > div.container.right > a.team-title');
sheet.getRange(3, 10).setValue(NomeTimeB.text());
}
正如Ouroborus提到的,每次调用PaginaDoJoJo()
只调用一个。
来自Cheerio
的语句只访问当前在contentText
中的UrlFetchApp.fetch
调用的结果。下面的代码现在访问$
,这是Cheerio
的结果感谢Cheerio
的展示。它似乎对抓取网站很有帮助,将来可能也会使用它。