By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,259 Members | 1,690 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,259 IT Pros & Developers. It's quick & easy.

improve string catching of html page

P: n/a
Hi all gurus in tha club,
I scripted a prog that extract a string from an html page excluding
all the tags.
The problem is that it works quite slowly and I wanted to know if
somebody of us as an idea how to improve his performance.

Thanks a lot
SHE

CODE

$start="start_str"; //begin string
$end="end_str"; //end string
if($snoopy->fetch("http://www.informative.page.com";)) //get the html
code
{

$string=$snoopy->results; //assign to $string all the html string

- Hide quoted text -
$i=1;
$line = explode("\n", $string); //trim the html in lines

while ($i<300)
{
//take only the middle
if ($i>230) {
//explode the line to control the content
$piece = explode(" ", $line[$i]);

$k=0;
while ($k<200) {

//if it content the string that i'm searching... :)
if ($piece[$k] == "interesting_part") {

$word=preg_split("/[\s<>]+/", $line[$i]); //to eliminate html tags

$j=1;
$flag=0; //to say when print the word

//extract the string without html
while ($word[$j]) {

if ($word[$j] == $begin) $flag = 1;
if ($word[$j] == $stop) $flag = 0;
if ($flag) echo "$word[$j] ";
$j++;
}

}
$k++;
}
}
$i++;
}
}
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Sheela wrote:
Hi all gurus in tha club,
I scripted a prog that extract a string from an html page excluding
all the tags.
The problem is that it works quite slowly and I wanted to know if
somebody of us as an idea how to improve his performance.

<snip>

I haven't closely looked at your code. But, looks like:
<?php
echo strpos(strip_tags(file_get_contents('http://www.example.com/')),
'to search');
?>
--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.