Solved

fetching all images from a URL

Posted on 2013-06-28
7
73 Views
Last Modified: 2015-02-27
i need to get images from a webpage source. i can use cfhttp to load page contents

need to loop through the content to get all image url's(src)

can i use rematch() or refind() etc... and if yes how??

if im not clear i can try to clarify..

with that, once i fetch images, i just want to specify to fetch images which has image size of 800*600 only

Any idea
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 15

Expert Comment

by:Tomarse111
ID: 39289980
This should do the trick for getting the images and checking their width and height:

<cfhttp url="YOUR_URL_HERE" method="get">
<cfset images = reMatchNoCase("<img ([^>]*[^/]?)>", cfhttp.FileContent)>


<cfloop array="#images#" index="img">
	<cfset src="YOUR_URL_HERE#REReplace(img, "^.*<img[^>]+src=(['""])([^'""]+)\1[^>]*>.*$", "\2")#">
	<cfset imgInfo=ImageNew(src)>
	
	<cfif imgInfo.width EQ 800 AND imgInfo.height EQ 600>
		
		<!--- DOWNLOAD IMAGE --->
		
	</cfif>
	
</cfloop>

Open in new window

0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 39292229
I am getting url like this

http://www.santabanta.com/photos/neha-dhupia/443114.htm?high=1http://media.santabanta.com/medium1/Global Celebrities(F)/Sunny Leone/sunny-leone-75a.jpg
0
 
LVL 15

Expert Comment

by:Tomarse111
ID: 39292434
Could you please show the code you are using, with the the CFHTTP url as well.

Tom
0
Use Filtering Commands to Process Files in Linux

Learn how to manipulate data with the help of various filtering commands such as `cat`, `fmt`, `pr`, and others in Linux.

 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 39295603
this is the code i used:

<cfhttp url="http://www.santabanta.com/photos/neha-dhupia/443114.htm?high=1" method="get">
<cfset images = reMatchNoCase("<img ([^>]*[^/]?)>", cfhttp.FileContent)>


<cfloop array="#images#" index="img">
	<cfset src="YOUR_URL_HERE#REReplace(img, "^.*<img[^>]+src=(['""])([^'""]+)\1[^>]*>.*$", "\2")#">
	<cfset imgInfo=ImageNew(src)>
	
	<cfif imgInfo.width EQ 800 AND imgInfo.height EQ 600>
		
		Using cfcontent here
		
	</cfif>
	
</cfloop>

Open in new window

0
 
LVL 15

Accepted Solution

by:
Tomarse111 earned 500 total points
ID: 39295910
Ah that's ok, the URLs for the img srcs are absolute (that's bad by the way) so you need line 6 to be changed:

<cfhttp url="http://www.santabanta.com/photos/neha-dhupia/443114.htm?high=1" method="get">
<cfset images = reMatchNoCase("<img ([^>]*[^/]?)>", cfhttp.FileContent)>


<cfloop array="#images#" index="img">
	<cfset src="#REReplace(img, "^.*<img[^>]+src=(['""])([^'""]+)\1[^>]*>.*$", "\2")#">
	<cfset imgInfo=ImageNew(src)>
		
	<cfif imgInfo.width EQ 800 AND imgInfo.height EQ 600>
		
		Using cfcontent here
		
	</cfif>
	
</cfloop>

Open in new window

0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 39820497
i tried the code but it does not fetch all images

this link

http://www.santabanta.com/wallpapers/neha-dhupia/

shows the images of the celebrity in thumbnail positions, with paging at the bottom, need to fetch the 800 *600 of all the images of the that celebrity, i know i am asking too much
0
 
LVL 16

Author Closing Comment

by:Gurpreet Singh Randhawa
ID: 40634918
Thanks, Changing few things made it work
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question