Solved

fetching all images from a URL

Posted on 2013-06-28
7
69 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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

751 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