On 9/3/00, [EMAIL PROTECTED] penned:
>Is there a way to actually extract information from URL's, like only the
>information you want, instead of the other stuff that you don't want?
If you view the source of the page you want, then say there is a
section that always changes dynamically and that is what you are
trying to get, and if you can find something before that that never
changes then you would do a "find()" for that string, then add the
number of characters to the position where you want to start your
extraction. Same thing for the end. Then your subtract the start
position from the end position and that would be the mid() function
you would run on it.
Example on a block of test that happens to be in a preformmated tag block:
<cfset begin = Find("<pre>", CFHTTP.FileContent)>
<cfset end = Find("</pre>", CFHTTP.FileContent)>
<cfset return = end - begin + 6>
We add the begin + 6 so it includes the end pre tag. The find on
</pre> returns the starting position of the < and we want the
starting position of the >.
So what you have is, if the first pre tag starts at position 400 and
the end pre tag starts at position 600, then we want to extract (600
- 400 + 6) or 206 characters starting at position 400, or:
<cfoutput>#mid(CFHTTP.FileContent, begin, return)#</cfoutput>
Which in reality is:
<cfoutput>#mid(CFHTTP.FileContent, 400, 206)#</cfoutput>
You can basically search for any text that is never going to change
and always be in the same position relative to the text you're trying
to extract. If the beginning search string is before the text you
want to extract, then add the number of characters (view the source,
count the line breaks also) to the content you want to extract.
Then you can add to the begin variable like this:
<cfset begin = Find("some html code", CFHTTP.FileContent) + 35>
Of course, if the code you are trying to search on has quotes or
pound signs in it, then I like to create a variable called
searchstring using the ascii code for the special characters.
Example, looking for <table width="95%" bgcolor="#ff0000">
<cfset searchstring = "<table width=" & chr(34) & "95% bgcolor=" &
chr(34) & chr(35) & "ff0000" & chr(34) & ">">
Then:
<cfset begin = Find(searchstring, CFHTTP.FileContent)>
Simple, huh? LOL
--
Bud Schneehagen - Tropical Web Creations
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
ColdFusion Solutions / eCommerce Development
[EMAIL PROTECTED]
http://www.twcreations.com/
954.721.3452
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.