CFHTTP parsing troubles, plz help
My client is a retailer and publishes on his website the items & prices exactly as they appear on the suppliers website.
The problem occured, when the wholesaler recently changed the structure of their webpages, yielding the parsing code obselete...
Now I'm coming into the picture, trying to rewrite everything, but I'm hitting some holes that I can't resolve.
Below I will post the code [partially] but I will briefly explain first what goes on.
On the suppliers website threre is a product table with multiple <tr> rows, and 6 <td> columns for every line item.
My client however is only publishing the contents of the first and third columns, and skip everything else.
For that, I need to loop once through the table to determine how many rows in the table. Then I need to nest a loop to determine and subtract the table cells contents.
Here I first parse the extra chars. etc.:
<cfhttp url="#trim(show_url.address)#?#show_tour.sport#" method="GET"></cfhttp>
<cfset Gfile =REplacenocase(#CFHTTP.FileContent#,'<tr class="results1">', '|', 'ALL')>
<cfset gfile = replacenocase(gfile,'<tr class="results2">', '|', 'ALL')>
<cfif Gfile DOES NOT CONTAIN "There are currently no dates/rates for this tour"
AND Gfile DOES NOT CONTAIN "Searched tour is not available">
<cfset gfile =listdeleteat(gfile,1, "|")>
<cfset gfile = replacenocase(gfile,"<tr>", "|", "ALL")>
<cfset gfile = replacenocase(gfile,"</tr>", "", "ALL")>
<cfset gfile = replacenocase(gfile,"<td >", "~", "ALL")>
<cfset gfile = replacenocase(gfile,"<TD class=", "~", "ALL")>
<cfset gfile = replacenocase(gfile,"</TD>", "", "ALL")>
<cfset gfile = replacenocase(gfile,"</TABLE>", "", "ALL")>
<cfset gfile = replacenocase(gfile,'<input type="button" name="btnResults" class="evSubmit" value="back to results"','')>
The next step is to populate the prices into the input form fields on the admin page:
<cfset records = listlen(gfile,"|")>
<cfif records GTE 1>
<cfloop index="rec" list="#gfile#" delimiters="|">
<cfset rec =listdeleteat(rec,3, "~")>
<cfset rec =replacenocase(rec, "'","","all")>
<cfset rec =replacenocase(rec, "?","")>
<cfset rec =replacenocase(rec, '"','','all')>
<cfset rec =replacenocase(rec, "onclick=document.location=/tours/Search.aspxAffiliateCode=&TrackingCode=>","","all")>
<cfoutput>
<cfset rec = replacenocase(rec, "mon, ","")>
<cfset rec = replacenocase(rec, "tue, ","")>
<cfset rec = replacenocase(rec, "wed, ","")>
<cfset rec = replacenocase(rec, "thu, ","")>
<cfset rec = replacenocase(rec, "fri, ","")>
<cfset rec = replacenocase(rec, "sat, ","")>
<cfset rec = replacenocase(rec, "sun, ","")>
<cfset rec = replacenocase(rec, "<p>","")>
<cfset td1 = listdeleteat(rec,1, "~")>
<cfset td2 = listdeleteat(rec,2, "~")>
<tr>
<th> <B>#COUNTER#.</B>
<cfloop index="td1" list="#trim(td1)#" delimiters="~">
<cfif isDate(trim(td1))><input type="Text" name="date#counter#" value="#dateFormat(td1,'dd/mmm/yyyy')#"></th><cfelse><th><input type="Text" name="price#counter#" value="#removeChars(trim(td1),1,1)#"></th> <th><select name="descript#counter#"><option value="1" SELECTED>Land Only<option value="2">Land and Air</select></th></tr></cfif>
</cfloop>
<cfset counter = #counter# + 1>
<tr><th> <B>#COUNTER#.</B>
<cfloop index="td2" list="#trim(td2)#" delimiters="~">
<cfif isDate(trim(td2))><input type="Text" name="date#counter#" value="#dateFormat(td2,'dd/mmm/yyyy')#"></th><cfelse><th><input type="Text" name="price#counter#" value="#removeChars(trim(td2),1,1)#"></th> <th><select name="descript#counter#"><option value="1">Land Only<option value="2" selected>Land and Air</select></th></tr></cfif>
</cfloop>
<cfset counter = #counter# + 1>
</cfoutput>
</cfloop>
</cfif>
<cfset counter = #counter# - 1>
<cfoutput>
<input type="hidden" name="PriceCount" value="#counter#">
<input type="hidden" name="OldPriceCount" value="#show_prices.recordCount#">
<input type="hidden" name="select_offer" value="#form.select_offer#">
</cfoutput>
And now the error:
| Error Occurred While Processing Request | ||||||||||||||||||
| ||||||||||||||||||
