Skip to content

Instantly share code, notes, and snippets.

@StefanYohansson
Last active February 4, 2018 15:07
Show Gist options
  • Select an option

  • Save StefanYohansson/a96c6a9b9619a4bc0dc6f57c3514fd50 to your computer and use it in GitHub Desktop.

Select an option

Save StefanYohansson/a96c6a9b9619a4bc0dc6f57c3514fd50 to your computer and use it in GitHub Desktop.
<?php
use Goutte\Client;
$client = new Client();
$politicians = [];
$url = 'http://www25.senado.leg.br/web/senadores/em-exercicio';
$response = $client->request('GET', $url);
$response->filter('tr')->each(function($node) use ($client) {
$class = $node->attr('class');
$tr = trim($node->text());
if ($class) {
$this->state = trim(explode('-', $tr)[0]);
$politicians[$this->state] = [];
} else {
$node->filter('td > a')->each(function($a) use ($client) {
$subresponse = $client->click($a->link());
var_dump($subresponse);die;
});
}
});
die;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment