Skip to main content
Inspiring
June 21, 2007
Question

cfhttp efforts continue

  • June 21, 2007
  • 2 replies
  • 298 views
I am not sure where to start on this so i thought I would post my delemma to the forums.

Yesterday I was struggling in finding a cfhttp solution that would allow me to download files that are on a particular page that I manually have to log into everyday to get at.

I realzed that I needed the custom tag cfx_http5 which manages the cookie and session issues.

Now here is my next problem.

On that page are a list of files. If you click those links they download. The links have a variable called batch_num

So it my look like this:

https://somethingcom/cehttp/servlet/MailboxServlet?operation=DOWNLOAD&mailbox_id=something&batch_num=0172735&data_format=A&batch_id=file.bleh

that batch number will be a random number or at least it is not a constant variable

the batch id file will always be the same.

So I am thinking I would need to search the URL for the batch_id and if it matches then some how I grab the file and download it.

How would you guys manage around that batch_number always changing?
functions or code examples would be very helpful...
    This topic has been closed for replies.

    2 replies

    Inspiring
    July 20, 2007
    <!--- search for keyword --->
    <cfif FindNoCase("q=", ReferringPage, 1)>
    <cfset StartText = "q=">
    <cfelseif FindNoCase("query=", ReferringPage, 1)>
    <cfset StartText = "query=">
    </cfif>

    <cfset Start = FindNoCase(StartText, ReferringPage, 1)>

    <cfif FindNoCase("&", ReferringPage, 1)>
    <cfset EndText = "&">
    <cfelseif FindNoCase("/", ReferringPage, 1)>
    <cfset EndText = "/">
    <cfelseif FindNoCase(" ", ReferringPage, 1)>
    <cfset EndText = " ">
    <cfelse>
    <cfset EndText = "">
    </cfif>

    <cfset EndText = "&">
    <cfset Length = Len(StartText)>

    <cfset End = FindNoCase(EndText, ReferringPage, Start)>
    <cfset End = Abs(End)>

    <cfset batchvalue = Mid(ReferringPage, Start+Length, Abs(End-Start-Length))>
    June 22, 2007
    Frank,

    First, parse out the link.
    Second, parse out the batch_id.

    Without seeing the html around the link, it's a bit hard to give you suggestions on how to get the link. But let's say that using the code below you can get the link and name it variable = linkcode.

    Here is some easy code to help you parse out the batch_id:

    <cfset StartText = "batch_num=">
    <cfset Start = FindNoCase(StartText, linkcode, 1)>
    <cfset EndText = "&">
    <cfset Length = Len(StartText)>
    <cfset End = FindNoCase(EndText, linkcode, Start)>
    <cfset batchvalue = Mid(linkcode, Start+Length, End-Start-Length)>

    Now you have batchvalue = 0172735. Then you can put it into whatever code you're using to grab the file.

    This should get you started in the right direction.

    cfwild