Puddinq.com sharing knowledge
';

scrape indeed

scrape indeed

add_shortcode('scrape-indeed', 'displayIndeedCompany');

function displayIndeedCompany() {

    $content =  file_get_contents('https://nl.indeed.com/cmp/Philips/reviews');

    $doc = new DOMDocument();
    libxml_use_internal_errors(true);
    $doc->loadHTML($content);
    libxml_use_internal_errors(false);
    $xpath = new DOMXpath($doc);

    $review_e = $xpath->query('(.//div[@data-tn-component="rating-histogram"])');
    $review =  $doc->saveHTML($review_e->item(0));

    return $review;


}

The above code outputs the company review on your site (example is for philips)