phplaravelweb-scrapingscrapygoutte

How to scrape inner html tag data from goutte and return in json format


I have used a Goutte package in laravel HTML CODE

<div class="middle-stats">
                <div class="wrap">
                    <div class="wrap-inner">
                        <ul class="mediaBodyStats">
                            <li><b>$16.1M</b> Price</li><li><b>47,503</b> Sqft</li><li><b>104.61</b> <div class="middle-stats middle-stats-mobile">
                    </div>

Try to access all list item as

private product_details = [];
    $page->filter('.middle-stats')->each(function($item){
        print_r($item->text());
        array_push($this->product_details, $item->text());
        

    });

how can i add list data in my array from laravel controller


Solution

  •     private product_details = [];
        $page->filter('.mediaBodyStats > li')->each(function($item){
            array_push($this->product_details, $item->text());
                });
    

    We can use inner html tags with ">" sign