Guys, I hope you can help me. im quite stuck already . Im trying to get all images in a given URL. Let say www.domain.com/gallery.html. it will extract all the thumbs. Thanks, Mike
Guys, by the way, what i mean here is that In a text box I'll write any website url and I want to get all of the image urls of the site. Thanks, Mike
Submit a url, then click Get Images! <html> <body> <form action=""> <input type="text" name="url" value=""> <input type="submit" value="Submit URL"> </form> <input type="button" value="Get Images!" onclick="geti();"><br> <textarea cols="40" rows="25"></textarea> <script type="text/javascript"> var textarea = document.getElementsByTagName("textarea")[0]; var images = document.getElementsByTagName("img"); function geti() { if (images.length == '') { alert("No images!"); return false; } for (var i=0; i<images.length; i++) { textarea.innerHTML=textarea.innerHTML+document.getElementsByTagName("img")[i].src+'\n'; } } </script> <div style="display:none;"> <?php include($_GET['url']) ?> </div> </body> </html> HTML:
Hi MMJ, tnx for the help. Unfortunately, it doesnt work for me. I started some and I used file_get_contents. Im not sure if CURL is better. Anyways here is my start-up code $url_handle=file_get_contents($gallery_url); $url_handle=str_replace("\n", ' ', $url_handle); $pattern="/a[\s]+[^>]*?href[\s]?=[\s\"\']+"."(.*?)[\"\']+.*?>"."([^<]+|.*?)?<\/a>/i"; if(preg_match_all($pattern, $url_handle, $matches)){ foreach($matches[1] as $url_image){ $url_image_filename=trim(basename($url_image)); list($filename, $extension)=explode(".", $url_image_filename); if($extension=="gif" || $extension=="jpeg" || $extension=="jpg" || $extension=="png" || $extension=="tif" || $extension=="tiff"){ if(substr($url_image, 0, 1)=="/"){ $valid_url_image=$url_domain_name.$url_image; }else{ $valid_url_image=$url_domain_name."/".$url_image; } } } } it works fine to me IF the TGP or gallery has a format something like this Entered URL: www.domain.com/gallery.html <a href="original_image.gif"><img src="thumbs_image.gif"></a> i was able to extract www.domain.com/original_image.gif my problem is that if the URL or given page doesnt have an a href="image".... in short, im having trouble with regex. Any ideas guys to extract all $images="(gif|jpeg|jpg|png|tif|tiff)"; which includes the relative or absolute URL. Like (relative url|absulute url)/$images in regex Thanks, Mike
What do you mean it doesn't work for you? What did you try? It works fine. It just has one bug but it still works. I tried it in FF & IE. Do you have a link to it?
Hi, i found one, this is what im trying to do http://demo.smartthumbs.com/st/admin/thumbscan.php?action=onefile&domain_id=1 username: demo password: demo try any tgp or gallery and it will extract only all thumbs, very awesome logic there. Any idea how it is done, but for sure its a preg_match_all() Thanks, Mike
It depends. Say all images are surrounded by a <div class="image"></div> Code (markup): tag. You could use an explode to get all the code inbetween that. Eg: $code = file_get_contents("http://www.domain.com/gallery.html"); $step1 = explode('<div class="image"></div>', $code); $step2 = explode('</div>', $step1[0]); return $step2[0] PHP: