2011-01-12 64 views
0

我想用这个来测量下载图片需要多长时间,然后我可以用其他内容类型进行相同的测量。使用phpcURL(libcurl)我如何只下载URL中的图片

我找到了一个相关的例子:并分享它。

 
# Parse the image tags 
$img_tag_array = parse_array($web_page['FILE'], ""); 
    if(count($img_tag_array)==0) 
{echo "No images found at $target\n"; exit; } 

DIY的共振是自动化,这是一个更大框架的一部分。

+2

每个URL引用只有一个资源。 “网址”上没有多个图片。 – mario 2011-01-12 10:42:43

回答

0

为什么不简单点击下载Google Chrome浏览器并使用Web Developer工具查看下载图片所需时间的详细统计信息?除非我误解了你想要做什么,否则你似乎已经过分复杂化了。

0

研究发现,做什么,我想要的功能,让我分享:

 

function download_images_for_page($target) 
{ 
    echo "target = $target\n"; 

    # Download the web page 
    $web_page = http_get($target, $referer=""); 

    # Update the target in case there was a redirection 
    $target = $web_page['STATUS']['url']; 

    # Strip file name off target for use as page base 
    $page_base=get_base_page_address($target); 

    # Identify the directory where iamges are to be saved 
    $save_image_directory = "saved_images_".str_replace("http://", "", $page_base); 

    # Parse the image tags 
    $img_tag_array = parse_array($web_page['FILE'], ""); 

    if(count($img_tag_array)==0) 
    { 
     echo "No images found at $target\n"; 
     exit; 
    } 

    # Echo the image source attribute from each image tag 
    for($xx=0; $xx