Skip to content

Instantly share code, notes, and snippets.

@hugofabricio
Last active July 16, 2017 12:47
Show Gist options
  • Save hugofabricio/3cdfec6dcd7ae8d68a0ee02e87517d73 to your computer and use it in GitHub Desktop.
Save hugofabricio/3cdfec6dcd7ae8d68a0ee02e87517d73 to your computer and use it in GitHub Desktop.
<?php
public function table()
{
$crawler = \Goutte::request('GET', 'http://globoesporte.globo.com/futebol/brasileirao-serie-c');
$list = [];
$teams = $crawler->filter('.tabela-times tbody tr')->each(function ($node) {
return $node;
});
foreach($teams as $key => $team):
$list[$key]['name'] = $team->filter('.tabela-times-time-link')->attr('title');
endforeach;
$table = $crawler->filter('.tabela-pontos tbody tr')->each(function ($node) {
return $node;
});
$i = 0;
foreach($table as $item):
$info = $item->filter('.tabela-pontos-ponto');
$position = $i + 1;
$list[$i]['posicao'] = $position;
$list[$i]['pontos'] = $info->text();
$list[$i]['jogos'] = $info->nextAll()->text();
$list[$i]['vitorias'] = $info->nextAll()->nextAll()->text();
$list[$i]['empates'] = $info->nextAll()->nextAll()->nextAll()->text();
$list[$i]['derrotas'] = $info->nextAll()->nextAll()->nextAll()->nextAll()->text();
$list[$i]['golsPro'] = $info->nextAll()->nextAll()->nextAll()->nextAll()->nextAll()->text();
$list[$i]['golsContra'] = $info->nextAll()->nextAll()->nextAll()->nextAll()->nextAll()->nextAll()->text();
$list[$i]['saldoGols'] = $info->nextAll()->nextAll()->nextAll()->nextAll()->nextAll()->nextAll()->nextAll()->text();
$list[$i]['percentual'] = $info->nextAll()->nextAll()->nextAll()->nextAll()->nextAll()->nextAll()->nextAll()->nextAll()->text();
$i++;
endforeach;
return $list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment