Skip to content

Instantly share code, notes, and snippets.

@helderjs
Created December 20, 2013 01:14
Show Gist options
  • Save helderjs/8048984 to your computer and use it in GitHub Desktop.
Save helderjs/8048984 to your computer and use it in GitHub Desktop.
Exemplo Goutte
<html>
<head>
<title>PHP Teste</title>
</head>
<body>
<?php
require_once 'goutte.phar';
$goutte = new Goutte\Client();
$baseURL = 'http://www.galaticosonline.com/';
$urlEndpoint = 'noticias/vitoria.html';
//class="description clearfix "
//$domSelector = 'body/div[@class="geral"]/div[@class="site"]/div[@class="secao"]/div[@class="description clearfix"]/li/p';
//$domSelector = '*/div[@class="posts"]/ul/li';
$domSelector = '//div[@class="posts"]/ul/li';
$crawler = $goutte->request('GET', $baseURL . $urlEndpoint);
$results = $crawler->filterXPath($domSelector)->each(function ($node, $i) {
return trim($node->text());
});
echo "<pre>";
var_dump($results);
echo "</pre>";
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment