problem related to counting occurrences of words in web documents

hello everyone, I the following article: http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_21771192.html#16172959, it's been presented an approach for counting within a specific web document the occurrences of a word. There's only one problem: when using large website (say www.cnn.com ) it's too slow. As consequence the application can't run. Does anyone know a solution to this problem or an alternative?
Please I would be very grateful if you can help me as it's very important for my current work
many thanks in advance
k
kugoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MontoyaProcess Improvement MgrCommented:
I think I'd do that with PHP and then have flash read the value of a variable in php. That would be much, much faster.

0
Aneesh ChopraCommented:
Here is the fixed code....

Now this code will not hang at all, page loading might take time,
it depends on size of page...

Just put this code in a new FLA's first frame and set the html page url in the code..
---------
//set the file name here....
var htmlFile = "http://www.google.com";
// set the word here...
var countThisWord = "google";
var myLoadVar = new LoadVars();
myLoadVar.ignoreWhite = true;
myLoadVar.onData = function(dat)
{
      if (dat != undefined)
      {
            processHtmlData(dat);
      } else
      {
            trace("page load failed");
      }
};
myLoadVar.load(htmlFile);
//
function processHtmlData(dat)
{
      dat = dat.toLowerCase();
      countThisWord = countThisWord.toLowerCase();
      tmp = dat.substring(dat.indexOf("<title>"), dat.indexOf("</title>")+8);
      //trace(tmp);
      dat = dat.split(tmp).join("~");
      //dat = dat.indexOf("<") != -1
      this.onEnterFrame = function()
      {
            if (dat.indexOf("<") != -1 && dat.indexOf(">") != -1)
            {
                  tmp = dat.substring(dat.indexOf("<"), dat.indexOf(">")+1);
                  dat = dat.split(tmp).join("~");
                  trace("processing....");

            } else
            {
                  processStep2(dat);
                  delete this.onEnterFrame;
            }
      };
}
function processStep2(dat)
{
      dat = dat.split("&nbsp;").join("~");
      dat = dat.split(" ").join("~");
      dat = dat.split("\n").join("~");
      dat = dat.split("\r").join("~");
      //
      dat = dat.split(countThisWord);
      //
      trace('"'+countThisWord+'" word occurance count is: '+int(dat.length-1));
}
-------------

Rgds
Aneesh
0
Aneesh ChopraCommented:
Ok, here is the best optimized code...

page loading take 5-15 seconds, and it gives the result instantly....

=======
var htmlFile = "http://www.cnn.com";
// set the word here...
var countThisWord = "Live";
var myLoadVar = new LoadVars();
myLoadVar.ignoreWhite = true;
myLoadVar.onData = function(dat)
{
      if (dat != undefined)
      {
            trace("loaded");
            dat = dat.toLowerCase();
            countThisWord = countThisWord.toLowerCase();
            dat = dat.split(countThisWord);
            //
            trace('"'+countThisWord+'" word occurance count is: '+int(dat.length-1));
      } else
      {
            trace("page load failed");
      }
};
myLoadVar.load(htmlFile);
===========


NOTE: this solution give 99.9% accurate results

Rgds
Aneesh
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kugoAuthor Commented:
aneesh, thanks thanks thanks a lot!!
i am extremely grateful to you!
k
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.