Skip to content

Instantly share code, notes, and snippets.

@CLCL

CLCL/composer.json

Last active Apr 7, 2016
Embed
What would you like to do?
composerでPHP 5.3用のgoutte(ウェブスクレーパー)をインストールする。
{
"require": {
"php": ">=5.3.3",
"fabpot/goutte": "~1.0"
}
}
curl -sS https://getcomposer.org/installer | php
php composer.phar install
<?php
require_once __DIR__ . '/vendor/autoload.php';
ini_set('default_charset', 'UTF-8');
define(USER_AGENT, 'Goutte/1.0.7');
$client = new Goutte\Client;
$client->setHeader('User-Agent', USER_AGENT);
$crawler = $client->request('GET', 'http://example.com/');
$crawler->filter('h1')->each(function($node) {
echo $node->text()."\n";
});
exit(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment