Logfile statistics - get words from position between other words
| From: | Svein O. Benn�s | Date: | Sat, 18 Jan 2003 18:55:47 +0000 |
| Subject: | Logfile statistics - get words from position between other words | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-132117@lists.php.net to get a copy of this message | ||
I'm trying to write a script that extracts some search-queries from a
logfile, but I'm having problems finding the right function to solve this
problem.
Below you'll find 4 lines from the log - the words I'm trying to extract are
(for now) written in capital letters, and they are always found between the
expression "query=" and "&hits=".
Straightforward; I am trying to get everything between "query=" and "&hits="
on each line, and output statistics on different search queries on a web
page. Probably an easy thing to do, but I'm kinda stuck on this one...
*****
192.168.0.1 - - [20/Dec/2002:12:19:24 +0100] "GET
/cgi-bin/search?query=WORD&hits=10&offset=0&clustering=yes&type=all&version=
3.1.0 HTTP/1.1" 200 917 ""0.0310 0.0000 0.0000 0
192.168.0.1 - - [20/Dec/2002:12:19:25 +0100] "GET
/cgi-bin/search?query=ANOTHERWORD&hits=10&offset=0&clustering=yes&type=all&v
ersion=3.1.0 HTTP/1.1" 200 917 ""0.0150 0.0000 0.0000 0
192.168.0.1 - - [20/Dec/2002:12:19:27 +0100] "GET
/cgi-bin/search?query=YETANOTHERWORD&hits=10&offset=0&clustering=yes&type=al
l&version=3.1.0 HTTP/1.1" 200 917 ""0.0310 0.0000 0.0000 0
192.168.0.1 - - [20/Dec/2002:12:19:53 +0100] "GET
/cgi-bin/search?query=AGAINWITHTHEWORD&hits=10&offset=0&qtf_lemmatize=true&r
pf_clustering:enabled=1&rpf_clustering:root=%2A&clustering=yes&type=all&vers
ion=3.1.0 HTTP/1.1" 200 980 ""0.0310 0.0000 0.0000 0
*****
TIA
svein@bennaes.com