如何使用curl从站点获取图像

How do I get images from a specific site inside html content?

See the example here .

Here http://www.techtunes.com.bd/android-apps/tune-id/214272 is the main post link. I'm scraping content inside div#content using php. But images in the post give 403.

How do I show that image? I'm using the Goutte Library

use it like this: call the function with $url the image path, and $filename the image stored path.

private function httpgetfile($url, $filename)
{
    $fp = fopen($filename, 'a+');
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($ch, CURLOPT_FILE, $fp);
    curl_exec($ch);
    curl_close($ch);
    fclose($fp);
    return;
}