2016-09-24 4 views
0

私は現在、Goutteという単純なPHPクローラーを使用しています。 Guzzleを使用してhttp GETリクエストを実行します。私はスクレープアクションを実行することができます。しかし、私は/ filter内部変数をエコーし​​ようとしているが、エラーUndefined variable: xを取得します。変数が定義されます。変数にフィルタを渡す正しい方法は何でしょうか?Guzzle/Goutte - 基本的な擦れ - 要求変数を渡す

$client = new Goutte\Client(); 
$crawler = $client->request('GET', 'http://github.com/'); 
$crawler = $client->click($crawler->selectLink('Sign in')->link()); 
$form = $crawler->selectButton('Sign in')->form(); 
$x  = "hello"; 
$crawler = $client->submit($form, array('login' => 'xxxxx', 'password' => 'xxxxx')); 
$crawler->filter('.flash-error')->each(function ($node) { 
    echo $x; 
    print $node->text() . "\n"; 
}); 

答えて