Solved

fetching all images from a URL

Posted on 2013-06-28
7
61 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
Question by:myselfrandhawa
  • 4
  • 3
7 Comments
 
LVL 15

Expert Comment

by:Tomarse111
Comment Utility
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 15

Author Comment

by:myselfrandhawa
Comment Utility
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
Comment Utility
Could you please show the code you are using, with the the CFHTTP url as well.

Tom
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 15

Author Comment

by:myselfrandhawa
Comment Utility
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
Comment Utility
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 15

Author Comment

by:myselfrandhawa
Comment Utility
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 15

Author Closing Comment

by:myselfrandhawa
Comment Utility
Thanks, Changing few things made it work
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now