0
如何凑使用goutte和laravel一个<a>
链接data-
属性?使用goutte scrape data-属性?
我想刮一个标签,像这样:
<a class="ProfileNav-stat ProfileNav-stat--link u-borderUserColor u-textCenter js-tooltip js-nav u-textUserColor" data-nav="following" href="/rogerhamilton/following" data-original-title="987,358 Following">
此<a>
链路内我想接着刮data-original-title
标签。
我的代码是:
$client = new Client();
// Hackery to allow HTTPS
$guzzleclient = new \GuzzleHttp\Client([
'timeout' => 60,
'verify' => false,
]);
// Hackery to allow HTTPS
$client->setClient($guzzleclient);
$crawler = $client->request('GET', 'url');
$elements = $crawler->filter('.ProfileNav-stat.ProfileNav-stat--link')->each(function($node){
$x = $node->filter('data-original-title');
dd($x);
});
,但它不返回正确的数据。