laravel 5的简单html dom解析器

Jen*_*sej 5 html parsing dom laravel

我可以在哪里找到laravel 5的简单html dom解析器?我正在寻找这样的想法:http://simplehtmldom.sourceforge.net/manual.htm

Lim*_*nte 15

我推荐FriendsOfPHP/Goutte,它当然是GitHub上最流行的PHP抓取工具之一.

调节器

$crawler->filter('a[class="o_title"][href]')->each(function ($node) {
    $hrefs[] = $node->attr('href'); 
});

return view('some-template', ['hrefs' => $hrefs]);
Run Code Online (Sandbox Code Playgroud)

视图

@foreach ($hrefs as $href)
    {{ $href }}
@endforeach
Run Code Online (Sandbox Code Playgroud)

在你的情况下,它将是:

$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));
Run Code Online (Sandbox Code Playgroud)