How I can get specific picture on a website using curl xpath in php

Through this code I can get the specific text but my problem is how I can get the specific picture on a website through this code. Can anyone help, I am stuck at this point.


ini_set('max_execution_time', 300);

function news($url,$path){


    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);



        $thispage= new DOMDocument;
        $xpath=new DOMXPath($thispage);
        return $status;

$a= news('','string(/html/body/div[2]/div/main/div/div/div[1]/article[1]/h2/a)');

echo $a;


Source: stackoverflow-php