Skip to main content
April 22, 2006
Answered

Extracting Data Out of cfhttp.fileContent Object

  • April 22, 2006
  • 13 replies
  • 1442 views
Guys i am sure you will come up with nice idea .
please have a look at this URL . http://wwwapps.ups.com/tracking/tracking.cgi?tracknum=1Z6706320354622939

Its returning package information about any ups package . i am retereiving this page throught <cfhttp> after then trying to just filter out Tracking Number | Status | Delivery information out of this whole page. i think i am running out of ideas . one idea is to clean html Tags using ReReplace even then how can i just extract the only required info ?
This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer Newsgroup_User
flooker wrote:
> If i am understanding you correct You are suggesting Flow some thing like . in
> IM clinet issue Command : that will invoke CFC which will send and e-mail to
> UPS along with all tracking number : my POP3 will receive reply mail , and then
> i can use that to display results in IM Clent. (Is not Time here an issue.) i

as i asked before, "what's the email lag?" i guess versus "how many times does
the cfhttp page scrapping fail?" or "how much time can you devote to monitoring
their return page & reacting to changes?" i guess the answer is test the email
lag & see how easy it is to parse & more importantly how reliable the data is.

> mean user sending command and then at the back end CFC is waiting for the mail
> to arrive to process it evetually ? please correct the flow if i am missing
> some thing .

a gateway listener is waiting on the backend, it would IM the user. grab the
basic POP3 gateway code from chapter 31's source code here:
http://www.forta.com/books/0321292693/

13 replies

Inspiring
April 23, 2006
flooker wrote:
> Guys i am sure you will come up with nice idea .
> please have a look at this URL .
> http://wwwapps.ups.com/tracking/tracking.cgi?tracknum=1Z6706320354622939

why not give their email tracking a shot? it says it returns plain text.
April 23, 2006
PauIH : thanks for reply but scope of problem is little different . what i am doing is to display the result (tracking info) with in IM client like Google talk using CF gateway . and rest of the processing using CFHTTP is hapenning within CFC . so i am afraid e-mail wont help . within IM the user will send a command like show | tracking number and then gateway will respondback with information . i am displaying the results i mean its working fine but DIV or Span Tags of Ups web site are not consistant thats is why i am facing some trouble .
April 23, 2006
well some how nasty solution is as followed ..

<cfhttp url=" http://wwwapps.ups.com/tracking/tracking.cgi" method="get">
<cfhttpparam name = "tracknum" type = "URL" value = "#track#">
</cfhttp>

<cfset hello = REReplace(#cfhttp.fileContent#, "<[^>]*>", "", "All")>

<cfset b = find("Status",#hello#)>
<cfset c = find("Eastern Time",#hello#)>
<cfset count = val(#c#) - val(#b#) >
<cfset res = mid(#hello#,#b#,#count#)>
<cfset res = wrap(#res#,400,true)>
<cfset res = REReplace(#res#, " ", "", "All")>

April 23, 2006
Oh yeah, what about 1Z6706320354622940?

What happens if your server gets moved out of eastern time?

Thank you for posting a perfect example, that I can link to, of how NOT to attack a problem like this.
April 23, 2006
you are absolutly right . that's why i said " nasty solution" . what i posted is just a work around . i know its not A best solution .
April 22, 2006
The answer is, don't do it.
Here are some options most to least preferable:
  1. Don't use UPS. They blow. Even the US post office is better.
  2. Sign up for and use UPS' web interface. See http://www.ups.com/e_comm_access/gettools_index?loc=en_US .
  3. Parse the html, as you are asking about. Since the UPS site is crappy, table-layout html with poor "content id"; you will have a rough go and will have to adjust your code every time UPS tweaks their site.