Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl use strict; use warnings; # Apache logs robots filter-outer # Author: Gary C. Wang # Contact: # Website: # Filename: norobotlog # # Usage: norobotlog [logfile_name] # # This script parses Apache log files and # filters out entries from IP addresses # that request "robots.txt" file, commonly # associated with webcrawlers and site indexers. # Prior to usage, check regexp to make sure it matches your log format +. # My log format is something like: # 192.168.0.xx - - [11/Jul/2004:22:25:22 -0400] "GET /robots.txt HTTP +/1.0" 200 78 my %robots; my $ip_ptn = '((\d{1,3}\.){3}\d{1,3})'; # this regexp matches IP addre +sses my @file = <>; #file from stdin # First, find out which IPs are associated with crawlers foreach (@file) { # ----- Adjust this pattern to match your log file ----- $robots{$1} ++ if m/^$ip_ptn .+?robots\.txt/; } # Then weed those out, printing only the ones that do not request robo +ts.txt foreach (@file) { if (m/$ip_ptn /) { print if ! defined $robots{$1}; } }

In reply to norobotlog by quartertone

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2023-09-22 18:20 GMT
Find Nodes?
    Voting Booth?

    No recent polls found