Solved

Filtering/Searching Some Text (cfhttp.fileContent)

Posted on 2004-04-20
7
203 Views
Last Modified: 2013-12-24
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:
     <cfoutput>#cfhttp.fileContent#</cfoutput>

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 Google.com 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?

0
Comment
Question by:champ_010
  • 3
  • 2
  • 2
7 Comments
 
LVL 35

Expert Comment

by:mrichmon
ID: 10869948
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.
0
 
LVL 17

Accepted Solution

by:
Tacobell777 earned 500 total points
ID: 10873150
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.
0
 
LVL 1

Author Comment

by:champ_010
ID: 10875256

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...
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 17

Expert Comment

by:Tacobell777
ID: 10875425
Yes if I remember correctly you replace string with cfhttp.fileContent
0
 
LVL 1

Author Comment

by:champ_010
ID: 10875793
Oh...so 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...
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 10879633
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 :

http://www.3leaf.com/resources/articles/regex.aspx
0
 
LVL 1

Author Comment

by:champ_010
ID: 10896821

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.

thanks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
URL redirect 4 56
Grub Broken on Ubuntu 16.04 LTS, Mate 1.14 GUI 5 219
Website Test Question 6 113
IIS 8.5 2 52
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now