Filtering/Searching Some Text (cfhttp.fileContent)

Hi I am new to this.  

I know that I can submit to a form using cfhttp and get the output to display by doing:

I don't really need the output to be displayed for the user, but I do need to go into this output and find some specific strings.

For example if I submitted a search string to the search textbox and the cfhttp.fileContent is all the results page for my search, how do I filter through the html of that returned page to locate only the words: "Results 1 - 10 of about 9,490,000 " so that I can insert that into my database.  I don't need to display the results page to anyone, I just need to grab that one sentence for my database.

This is a wild uneducated guess but do I specify a 'file' and 'path' to save the results page to and in that page make some kind of function that locates the required text and inserts into database and toss out the rest?

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

Tacobell777Connect With a Mentor Commented:
I quickly typed this and did not test it

<cfset result = reFindNoCase("Results\s*\d*\-\d*of about [0-9,]", string, 1, "true")>

<cfdump var="#result#">

result will give you a structure that contains the position and length of where the value was found, you can then use mid to retrieve the value.
You could use a regular expression to search through the results to find the sentence you are looking for.  I would guess that you could just search on the variable instead of printing it to a page.
champ_010Author Commented:

So I do specify file and path in the cfhttp and then inside the specified file is where I use something like the code shown by Tacobell777?

Sorry I'm new to this and still trying to figure out the regular expression and this reFindNoCase thing.  Will try it out...
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Yes if I remember correctly you replace string with cfhttp.fileContent
champ_010Author Commented: in that case I don't have to save the stuff to a file...I can just use your code on the cfhttp.fileContent and go from there.

Will try it...
Exaclty.  And if the RE that TacoBell doesn't work - it is a good starting point and you can use pages such as this for more help with writing/adjusting it :
champ_010Author Commented:

o.k. I read up on some of this reFindNoCase thing and finally got around to the regExp stuff.  I didn't actually try out Tachobell777 code, but it makes sense to me now--especially the part about applying it to the cfhttp.fileContent.

All Courses

From novice to tech pro — start learning today.