473,320 Members | 1,817 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,320 software developers and data experts.

Analysing simple weblog

Hi,

I have few weblogs, example below
65.96.112.177 - - [27/Jan/2007:00:02:10 -0500] "GET /~jking/images/ralph.jpg HTTP/1.1" 200 66196
65.214.44.44 - - [27/Jan/2007:00:02:27 -0500] "GET /~jkabara/Research.htm HTTP/1.0" 200 4696
207.46.98.52 - - [27/Jan/2007:00:02:29 -0500] "GET /~mweiss/new/background.htm HTTP/1.0" 200 3905
207.46.98.52 - - [27/Jan/2007:00:02:35 -0500] "GET /%7Epaws/project_pacer.htm HTTP/1.0" 200 15645
207.46.98.52 - - [27/Jan/2007:00:02:36 -0500] "GET /%7Espring/patterns/node15.html#SECTION00042300000000000000 HTTP/1.1" 200 2641
65.214.44.44 - - [27/Jan/2007:00:02:42 -0500] "GET /~jkling/2110/week04.ppt HTTP/1.0" 200 1914280

Basically... I want to find out, which page did the user start browsing and which page he ended.

The output should be something like
Visitor 65.96.112.177 started browsing at page /~jking/images/ralph.jpg
Visitor 65.96.112.177 ended browsing at page /~jking/images/ralph.jpg
Visitor 65.214.44.44 started browsing at page /~jkabara/Research.htm
Visitor 65.214.44.44 ended browsing at page /~jkling/2110/week04.ppt
.
.
.
.


I wrote the code below assuming that, if the ip doesnt match at the 20th time...it means...the user ended his session. But it aint happening..could someone please help me do this...any other solutions/ideas are welcome

Expand|Select|Wrap|Line Numbers
  1.     open (INF, $logfile);
  2.     read INF, $file, -s INF;
  3.     close INF;
  4.  
  5.     @lines = split /\n/, $file;
  6.  
  7.     foreach (@lines) {
  8.     @values = split / /, $_;
  9.     $visitors{$values[0]}++;
  10.     }
  11.     $maxcount=20;
  12.     $timecounter=250;
  13.     foreach $visitor (keys %visitors)
  14.     {
  15.         $flag = 0 ;
  16.         foreach $logentry (@lines)
  17.         {
  18.             @values = split / /, $logentry;
  19.             if($visitor eq $values[0])
  20.             {
  21.                 $currentpage = $values[6];
  22.                 if($flag==0){
  23.                     print "\n Visitor " . $visitor . " started checking out the page";            
  24.                     print ":     " .$values[6] . " ";
  25.                     $startpage = $values[6];
  26.                     $flag=1;
  27.                     $i=0;    
  28.                     $endpage = $values[6];
  29.                     }
  30.                 else{
  31.                     $endpage = $values[6];
  32.                     }
  33.             }#if 
  34.             else{
  35.                 $i++;
  36.                 }
  37.             if($i > $maxcount) {print "\nLast Page Visited by " . $visitor . " was " .$endpage . " ";last;}                
  38.             print "\ni=" .$i;
  39.         }#for each line
  40.     }#for each visitor
  41.  
Mar 16 '10 #1
1 1140
Expand|Select|Wrap|Line Numbers
  1. open (INF, $logfile);
  2. read INF, $file, -s INF;
  3. close INF;
  4.  
  5. @lines = split /\n/, $file;
  6.  
  7. foreach (@lines)
  8. {
  9.    @values = split / /, $_;
  10.    $visitors{$values[0]}++;
  11.    if ($visitors{$values[0]} == 1 )
  12.    {
  13.       # Get starting web page
  14.       $report{$values[0]}[0] = "$values[6]";
  15.       # When a user start browsing
  16.       # considering this will be a first page as well as endpage
  17.       $report{$values[0]}[1] = "$values[6]";  
  18.    }
  19.    else
  20.    {
  21.      # Get last web page
  22.      $report{$values[0]}[1] = $values[6];   
  23.    }
  24. }
  25.  
  26. foreach my $key (keys %report)
  27. {
  28.   for my $i (0 .. 1 ) ## 0 -> For starting page 1-> For ending page
  29.   {
  30.     print "\n\nVisitor $key started browsing at page $report{$key}[$i]" if ($i == 0);
  31.     print "\nVisitor $key ended browsing at page $report{$key}[$i]" if ($i == 1);
  32.   }
  33. }
  34.  
Mar 16 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: S.Chang | last post by:
Hi, just a quick question, what kind of system load to expect to run a medium/large scale weblog? the back end servers will be updaing the page quiet often, almost once per minute per servers. ...
0
by: Xavier Seneque | last post by:
hello, i'm trying to parse an XML file from a java program, and the structure of the XML document is described in a schema file. here is the simple schema file (departement.xsd) : <?xml...
14
by: Brandon | last post by:
I am an amateur working on a first site, I have settled on using FP 2002 for now. My current page is up and live, but I have two errors that I cant seem to get rid of ... Line 29, column 6:...
14
by: Ian | last post by:
Hi I just started with C# and already i have a problem. i need to transalt this line from VB6 to C#. txtAnswer.text = (txtNumberOne.text - 32) * 5/6 Thanks
5
by: Le, Thanh-Nhan | last post by:
Hi, I want to send a simple mail with C#. I have tried the following, but they don't work: - some solutions on CodeProject websites. - shellExecute(mailto:xxx@yyy.com?subject=aaa&body=bbb). ...
13
by: tindog | last post by:
I am brand new to this programming especially C#. I am confused (at the moment). I have bought two books to get started to learn C# language and Visual C#.net 2003 in 24 hours. Which is the best to...
2
by: Jon Delano | last post by:
Hello I'm looking for a simple TIFF viewer for a vb.net web application. The TIFFs are single page and I just need to display them and that is it ... nothing fancy at all. Anyone have a...
7
by: Michael Peters | last post by:
I need a simple editor to edit the texts in static html pages. Is there a program for that? It should be something very simple, nothing like Dreamweaver. I don't need to edit any tables,...
1
by: Roman Ziak | last post by:
I switched to Windows server and logs generated by my ISP are pathetic comparing to those from Apache. I would like to do logging via PHP and use the same log for visits and for PHP tracing. That...
5
by: Davo1977 | last post by:
Analysing text files to obtain statistics on their content You are to write a Perl program that analyses text files to obtain statistics on their content. The program should operate as follows: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.