Last active
February 4, 2018 15:07
-
-
Save StefanYohansson/a96c6a9b9619a4bc0dc6f57c3514fd50 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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