Skip to main content
Inspiring
October 6, 2008
Question

webservice query

  • October 6, 2008
  • 1 reply
  • 294 views
Hi, I Just Plyed around webservices and they are really
cool.

while I was doing work, I came across one Probel.

I was trying how to extract a random joke from a
website and give it a shape of a webservice,

I tried using the cfhttp tag but that fetched the whole
page.

Can Anyone guide how can I complete this Process.

The page i am trying to get IS:

http://www.ybored.com//index.php?
ACT=jksdisplay&jksid=1899

Cheers
This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
October 6, 2008
This one's twice as much fun. I presume you know that a web service request is different from cfhttp.

When you make a cfhttp request you're actually playing the role of browser. That is why the whole page poured down on you. You have to do the filtering yourself.

Start by looking at the source code of the page in the browser. You will see that the author has made things easy for us. He or she has put the jokes in a table whose class attribute is "jokeContents". Neat. What you have to do is to treat the page content as a string, locate the table as a substring and extract it. The following code does just that.

Have fun. Oh, and, I liked the husband and wife one, where rupees change hands. Hilarious.