473,388 Members | 1,286 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

improve string catching of html page

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
1 1453
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ed | last post by:
I am building a glossary. Each letter of the alphabet has its own HTML page, and each glossary entry on the page already has a unique HTML anchor tag immediately to the left of it. I've already...
3
by: perlet | last post by:
This is a script I found elsewhere that I was hoping to tweak to do something just a little different. Can't figure out its error. I wouln't mind paying someone to help out if needed to get it to run...
25
by: JJ | last post by:
I only want to catch 404 errors at the application level (the rest are will be handled by the customerrors section of the web.config). How do I check for the error code in the Application_Error...
14
by: Donn Ingle | last post by:
Yo, An app of mine relies on PIL. When PIL hits a certain problem font (for unknown reasons as of now) it tends to segfault and no amount of try/except will keep my wxPython app alive. My first...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.