Scraping Data From A Table From A Specific Title Value And Filter Specific Lines (google App Script)
Documentation for CherrioGS: https://github.com/tani/cheeriogs The idea is to collect only data from the table with the name Argentinos Jrs and that lines with the value Away on In
Solution 1:
function PaginaDoJogo() {
const sheet = SpreadsheetApp.getActive().getSheetByName('Dados Importados');
const url = 'https://www.sportsgambler.com/injuries/football/argentina-superliga/';
const response = UrlFetchApp.fetch(url);
const content = response.getContentText();
const match = content.match(/Argentinos Jrs[\s\S]+?<!--Livestream call to action-->/);
const regExp = /<div[\s\S]+?<span class="inj-player">(.+?)<\/span>[\s\S]+?<span class="inj-info">(.+?)<\/span>[\s\S]+?<span class="inj-return h-sm">(.+?)<\/span>[\s\S]+?<\/div>/g;
const values = [];
while ((r = regExp.exec(match[0])) !== null) {
// console.log(r[1], r[2], r[3]);
if (r[1] !== 'Name' && r[2] !== 'Away on International duty') {
values.push([r[1], r[3]]);
}
}
sheet.getRange(2, 1, values.length, 2).setValues(values);
}
Post a Comment for "Scraping Data From A Table From A Specific Title Value And Filter Specific Lines (google App Script)"