For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > December 2004 > search script for html page content









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author search script for html page content
Rolf Brauser

2004-12-29, 3:56 pm

Hi,

I´m looking for a small script which parses html page content and gives back
the link where the hit was made.

does someone know where I can get those lines ?

thanks for any help!

Rolf


Janwillem Borleffs

2004-12-29, 3:56 pm

Rolf Brauser wrote:
> I´m looking for a small script which parses html page content and
> gives back the link where the hit was made.
>
> does someone know where I can get those lines ?
>


How about using $_SERVER['HTTP_REFERER']?

This will contain the referring page when available...


JW



Rolf Brauser

2004-12-29, 3:56 pm


> How about using $_SERVER['HTTP_REFERER']?


Hi,
do you have links or exampes how that works ?
Rolf


Hilarion

2004-12-29, 3:56 pm

> > How about using $_SERVER['HTTP_REFERER']?
>
> do you have links or exampes how that works ?


If you have two WWW pages "a.html" and "b.php"
on "http://some.server/path/", which look like
this:

a.html:

<html>
<body>
<a href="b.php">move to b.php</a>
</body>
</html>

b.php:

<html>
<body>
<?php
echo 'You came from: ' . htmlspecialchars( $_SERVER['HTTP_REFERER'] );
?>
</body>
</html>


then when user clicks on the link in "a.html" page
and his browser knows how to pass Referer information,
then the "b.php" page will display something like:
You came from: http://some.server/path/a.html

Hilarion


Rolf Brauser

2004-12-29, 3:56 pm


"Hilarion" <hilarion@SPAM.op.SMIECI.pl> wrote in message
news:cqulq9$ert$1@news.onet.pl...
>
> If you have two WWW pages "a.html" and "b.php"
> on "http://some.server/path/", which look like
> this:
>
> a.html:
>
> <html>
> <body>
> <a href="b.php">move to b.php</a>
> </body>
> </html>
>
> b.php:
>
> <html>
> <body>
> <?php
> echo 'You came from: ' . htmlspecialchars( $_SERVER['HTTP_REFERER'] );
> ?>
> </body>
> </html>
>
>
> then when user clicks on the link in "a.html" page
> and his browser knows how to pass Referer information,
> then the "b.php" page will display something like:
> You came from: http://some.server/path/a.html
>
> Hilarion


Hilarion,
I understand but this is not what i need.
I need a php programm which I feed with a string, then openes one or more
directories of my choice (with all files in it) and looks for matches of
this string, but only outside the html brackets, not the html code.
Than it should output the line or the filename (refferer?) where this match
was.
Rolf


Hilarion

2004-12-29, 3:56 pm

> I understand but this is not what i need.
> I need a php programm which I feed with a string, then openes one or more
> directories of my choice (with all files in it) and looks for matches of
> this string, but only outside the html brackets, not the html code.
> Than it should output the line or the filename (refferer?) where this match
> was.


So "Referer" has nothing to do with it. There are also no "hits" (which
you mentioned in the original post) in this problem.
Why do you want to use PHP for such thing? Use "egrep" or something like
that (maybe from PHP script). If you are going to use PHP, than
check functions:
- opendir, readdir, closedir (to list directory contents),
- file_get_contents (to read textfile contents into string),
- strip_tags (to strip all HTML tags from file leaving only plain text;
it strips also attributes, so if you want to look in HREFs, then
this function is not the one you look for),
- explode, split (to split text into portions - eg. lines),
- strpos, stripos, ereg etc. (to find some text in a string).

If you want to build some stats for your webpages then it's not the way.

Hilarion


Rolf Brauser

2004-12-30, 8:56 am

> So "Referer" has nothing to do with it. There are also no "hits" (which
> you mentioned in the original post) in this problem.
> Why do you want to use PHP for such thing? Use "egrep" or something like
> that (maybe from PHP script). If you are going to use PHP, than
> check functions:
> - opendir, readdir, closedir (to list directory contents),
> - file_get_contents (to read textfile contents into string),
> - strip_tags (to strip all HTML tags from file leaving only plain text;
> it strips also attributes, so if you want to look in HREFs, then
> this function is not the one you look for),
> - explode, split (to split text into portions - eg. lines),
> - strpos, stripos, ereg etc. (to find some text in a string).
>
> If you want to build some stats for your webpages then it's not the way.
>
> Hilarion

Hi,
Ok, then I will glue it together by myself, shoud be no problem afer your
nice list. Thanks !!
I know all exept : strpos, stripos, ereg. But I´ll gonna check that out on
PHP net.
I thought there are some free scritps for that purpose on the net. Goodbye
hollydays. : )
Thanks
Klaus


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com