Jump to content

Getting Images from a Website to Create Gallery


nz_mitch

Recommended Posts

Hi there

 

We're trying to collect just the images from a website so we can show them as a gallery without the additional details on the standard page. The photos we need are the high res images which show up in a lightbox. The existing HTML looks like this:

 

<div id="photoBrowse" class="photos"> 
    <div class="photoLrge"> 
        <a class="fancybox primary" rel="photos" style="background-image:url(http://photos.harcourts.co.nz/011/568/024-MJ3563-Eversleigh-Road-Takapuna-North-Shore-City-Auckland-New-Zealand.jpg);" href="http://photos.harcourts.co.nz/011/568/023-MJ3563-Eversleigh-Road-Takapuna-North-Shore-City-Auckland-New-Zealand.jpg" title=""> 
            <img src="http://photos.harcourts.co.nz/011/568/024-MJ3563-Eversleigh-Road-Takapuna-North-Shore-City-Auckland-New-Zealand.jpg" /> 
        </a><a class="fancybox hidden" rel="photos" href="http://photos.harcourts.co.nz/011/544/027-MJ3563-Eversleigh-Road-Takapuna-North-Shore-City-Auckland-New-Zealand.jpg" title=""></a><a class="fancybox hidden" rel="photos" href="http://photos.harcourts.co.nz/011/567/950-MJ3563-Eversleigh-Road-Takapuna-North-Shore-City-Auckland-New-Zealand.jpg" title=""></a><a class="fancybox hidden" rel="photos" href="http://photos.harcourts.co.nz/011/567/942-MJ3563-Eversleigh-Road-Takapuna-North-Shore-City-Auckland-New-Zealand.jpg" title=""></a><a class="fancybox hidden" rel="photos" href="http://photos.harcourts.co.nz/011/567/982-MJ3563-Eversleigh-Road-Takapuna-North-Shore-City-Auckland-New-Zealand.jpg" title=""></a><a class="fancybox hidden" rel="photos" href="http://photos.harcourts.co.nz/011/567/999-MJ3563-Eversleigh-Road-Takapuna-North-Shore-City-Auckland-New-Zealand.jpg" title=""></a><a class="fancybox hidden" rel="photos" href="http://photos.harcourts.co.nz/011/567/990-MJ3563-Eversleigh-Road-Takapuna-North-Shore-City-Auckland-New-Zealand.jpg" title=""></a><a class="fancybox hidden" rel="photos" href="http://photos.harcourts.co.nz/011/567/974-MJ3563-Eversleigh-Road-Takapuna-North-Shore-City-Auckland-New-Zealand.jpg" title=""></a><a class="fancybox hidden" rel="photos" href="http://photos.harcourts.co.nz/011/568/007-MJ3563-Eversleigh-Road-Takapuna-North-Shore-City-Auckland-New-Zealand.jpg" title=""></a><a class="fancybox hidden" rel="photos" href="http://photos.harcourts.co.nz/011/544/035-MJ3563-Eversleigh-Road-Takapuna-North-Shore-City-Auckland-New-Zealand.jpg" title=""></a><a class="fancybox hidden" rel="photos" href="http://photos.harcourts.co.nz/011/568/015-MJ3563-Eversleigh-Road-Takapuna-North-Shore-City-Auckland-New-Zealand.jpg" title=""></a><a class="fancybox hidden" rel="photos" href="http://photos.harcourts.co.nz/011/544/003-MJ3563-Eversleigh-Road-Takapuna-North-Shore-City-Auckland-New-Zealand.jpg" title=""></a><a class="fancybox hidden" rel="photos" href="http://photos.harcourts.co.nz/011/544/019-MJ3563-Eversleigh-Road-Takapuna-North-Shore-City-Auckland-New-Zealand.jpg" title=""></a><a class="fancybox hidden" rel="photos" href="http://photos.harcourts.co.nz/011/568/031-MJ3563-Eversleigh-Road-Takapuna-North-Shore-City-Auckland-New-Zealand.jpg" title=""></a><a class="fancybox hidden" rel="photos" href="http://photos.harcourts.co.nz/011/568/047-MJ3563-Eversleigh-Road-Takapuna-North-Shore-City-Auckland-New-Zealand.jpg" title=""></a> 
    </div>     

 

I've tried do something like the following, but this is really beyond what I can figure out. Any help would be really appreciated:

include('simple_html_dom.php');
$url = "http://www.harcourts.co.nz/Property/View/MJ3563/38a-Eversleigh-Road";
$dom = file_get_html($url);
$testdiv = $dom->find('a.imageBrowse',0); // 0 for the first occurrence
$testdiv_contents = $testdiv->innertext;
echo '<pre>';
print_r($testdiv_contents);
echo '</pre>';

 

I've also tried something like this, based on the code available here:

function scraping_24() { // 
// get news block
$url = "http://www.harcourts.co.nz/Property/View/MJ3563/38a-Eversleigh-Road";
$html = file_get_html('http://www.harcourts.co.nz/Property/View/MJ3563/38a-Eversleigh-Road');
foreach($html->find('div.photoLrge') as $article) {
    // get image
    $item['photo'] = trim($article->find('a.fancybox', 0)->plaintext);
  
    $ret[] = $item;
}

// clean up memory
$html->clear();
unset($html);
return $ret;
}

 

I've tried to make sense of the PHP guide on DOM... I'm really sorry that I'm asking for help for something I have so little understanding of, but I've been at this for hours and I just can't crack it.

 

Thanks

Mitch

 

 

 

 

Link to comment
Share on other sites

Hello! This forum has many experts, I however am sort of a noob but allow me to suggest something. First off have you considered using cURL? http://php.net/manual/en/book.curl.php  I use cURL to download thumbnail images from Youtube but I use the .jpg extension.  Also it might be easier if you retrive images from the website's slideshow image folder, if you have access to it via  HTTP

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.