我在哪里可以找到适用于 laravel 5 的简单 html dom 解析器? 我正在寻找这样的想法:http://simplehtmldom.sourceforge.net/manual.htm
最佳答案
我推荐FriendsOfPHP/Goutte ,它当之无愧是 GitHub 上最受欢迎的 PHP 爬虫之一。
Controller
$crawler->filter('a[class="o_title"][href]')->each(function ($node) {
$hrefs[] = $node->attr('href');
});
return view('some-template', ['hrefs' => $hrefs]);
查看
@foreach ($hrefs as $href)
{{ $href }}
@endforeach
在你的情况下它将是:
$crawler = $client->request(
'GET',
'http://www.oglaszamy24.pl/ogloszenia/nieruchomosci/domy/?std=1&results=100000'
);
$text = $crawler->filter('.resultpages_current')->text();
$numPages = intval(preg_replace('/[^0-9]/', '', $text));
关于html - laravel 5 的简单 html dom 解析器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29067113/