<!--- Photo pages in form of: http://www.oxpe.net/playboy/playboy195401.html Photos in form of: http://www.oxpe.net/playboy/photos/195401.jpg Available Years: 1954 - 2007 ---> <!--- Set a high request timeout - there are a LOT of images to be downloading here. ---> <cfsetting requesttimeout="500" /> <!--- Loop over available years. ---> <cfloop index="intYear" from="1954" to="2007" step="1"> <!--- Loop over available months. ---> <cfloop index="intMonth" from="1" to="12" step="1"> <!--- Get the short hand for the file name. All the months have to be double-digits. ---> <cfset strName = ( intYear & NumberFormat( intMonth, "00" ) ) /> <!--- Set up base URL that will be used by both the CFHttp target as well as the referer. ---> <cfset strBaseURL = "http://www.oxpe.net/playboy/" /> <!--- Echo back the photo we are trying to get. ---> <p> <cfoutput> #strName#.jpg </cfoutput> </p> <!--- Perform an HTTP GET to grab the target image as binary. CAUTION: Once we go beyond the vailable year/months (ex. 2007/12), this will come back with 200 status, but NOT be a valid image binary. ---> <cfhttp method="get" url="#strBaseURL#photos/#strName#.jpg" useragent="#CGI.http_user_agent#" getasbinary="yes" result="objGET"> <!--- Set CGI referrer to be the page that it was called from. We want to fake the target server into thinking we just came from an internally hosted page. ---> <cfhttpparam type="CGI" name="referer" value="#strBaseURL#playboy#strName#.html" /> </cfhttp> <!--- Check status. ---> <cfif FindNoCase( "200", objGET.StatusCode )> <!--- Save file. ---> <cffile action="write" file="#ExpandPath( './#strName#.jpg' )#" output="#objGET.FileContent#" /> </cfif> <p> <cfoutput> » <em>#objGET.StatusCode#</em> </cfoutput> </p> <cfflush /> </cfloop> </cfloop>