Reputation: 2137
I have a question regarding the structural part of calls, there is a limitation of 1,000 daily calls to UrlFetchApp
, in the model used in my example code, how many UrlFetchApp
calls are used?
Only one and from it are worked on each of the four var
lines below or is a four UrlFetchApp
call needed?
Documentation:
https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app
Add Info, documentation for 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());
}
Upvotes: 0
Views: 83
Reputation: 11214
As Ouroborus mentioned, just one every time PaginaDoJoJo()
is called.
The statement from Cheerio
only accesses the result from that one UrlFetchApp.fetch
call which was in contentText
right now. The ones below it now accesses the $
which was the result of Cheerio
Thanks for showing Cheerio
. It seems very helpful in scraping a site and might use it as well in the future.
Upvotes: 1