Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple html dom parser for laravel 5

where I can find simple html dom parser for laravel 5? I'm looking for somethink like this: http://simplehtmldom.sourceforge.net/manual.htm

like image 204
Jensej Avatar asked Mar 15 '15 22:03

Jensej


People also ask

What is simple HTML DOM parser?

A Simple HTML DOM parser written in PHP let you manipulate HTML in a easy way with selectors just like CSS or jQuery. This is modern version of Simple HTML DOM. You can install by using Composer and import to your project as a package.

What is simple dom?

PHP Simple HTML DOM ParserA fast, simple and reliable HTML document parser for PHP. Created by S.C. Chen, based on HTML Parser for PHP 4 by Jose Solorzano.

What is DOM parsing web scraping?

The web scraping can be done by targeting the selected DOM components and then processing or storing the text between that DOM element of a web page. To do the same in PHP, there is an API which parses the whole page and looks for the required elements within the DOM. It is the Simple HTML DOM Parser.


1 Answers

I recommend FriendsOfPHP/Goutte, it's deservedly one of the most popular PHP crawlers on GitHub.

Controller

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

return view('some-template', ['hrefs' => $hrefs]);

View

@foreach ($hrefs as $href)
    {{ $href }}
@endforeach

In your case it will be:

$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));
like image 188
Limon Monte Avatar answered Oct 19 '22 13:10

Limon Monte