5 use WWW::RobotRules::AnyDBM_File;
9 $r = new WWW::RobotRules::AnyDBM_File "myrobot/2.0", $file;
11 $r->parse("http://www.aas.no/robots.txt", "");
13 $r->visit("www.aas.no:80");
15 print "not " if $r->no_visits("www.aas.no:80") != 1;
19 $r->push_rules("www.sn.no:80", "/aas", "/per");
20 $r->push_rules("www.sn.no:80", "/god", "/old");
22 @r = $r->rules("www.sn.no:80");
25 print "not " if "@r" ne "/aas /per /god /old";
28 $r->clear_rules("per");
29 $r->clear_rules("www.sn.no:80");
31 @r = $r->rules("www.sn.no:80");
34 print "not " if "@r" ne "";
37 $r->visit("www.aas.no:80", time+10);
38 $r->visit("www.sn.no:80");
40 print "No visits: ", $r->no_visits("www.aas.no:80"), "\n";
41 print "Last visit: ", $r->last_visit("www.aas.no:80"), "\n";
42 print "Fresh until: ", $r->fresh_until("www.aas.no:80"), "\n";
44 print "not " if $r->no_visits("www.aas.no:80") != 2;
47 print "not " if abs($r->last_visit("www.sn.no:80") - time) > 2;
52 # Try to reopen the database without a name specified
53 $r = new WWW::RobotRules::AnyDBM_File undef, $file;
54 $r->visit("www.aas.no:80");
56 print "not " if $r->no_visits("www.aas.no:80") != 3;
59 print "Agent-Name: ", $r->agent, "\n";
60 print "not " if $r->agent ne "myrobot";
65 print "*** Dump of database ***\n";
66 tie(%cat, AnyDBM_File, $file, 0, 0644) or die "Can't tie: $!";
67 while (($key,$val) = each(%cat)) {
74 # Try to open database with a different agent name
75 $r = new WWW::RobotRules::AnyDBM_File "MOMSpider/2.0", $file;
77 print "not " if $r->no_visits("www.sn.no:80");
81 $r->parse("http://www.sn.no:8080/robots.txt", <<EOT, (time + 3));
92 @r = $r->rules("www.sn.no:8080");
93 print "not " if "@r" ne "/foo /bar";
96 print "not " if $r->allowed("http://www.sn.no") >= 0;
99 print "not " if $r->allowed("http://www.sn.no:8080/foo/gisle");
102 sleep(5); # wait until file has expired
103 print "not " if $r->allowed("http://www.sn.no:8080/foo/gisle") >= 0;
109 print "*** Dump of database ***\n";
110 tie(%cat, AnyDBM_File, $file, 0, 0644) or die "Can't tie: $!";
111 while (($key,$val) = each(%cat)) {
112 print "$key\t$val\n";
116 untie %cat; # Otherwise the next line fails on DOSish
118 while (unlink("$file", "$file.pag", "$file.dir", "$file.db")) {}
120 # Try open a an emty database without specifying a name
122 $r = new WWW::RobotRules::AnyDBM_File undef, $file;
125 print "not " unless $@; # should fail
128 unlink "$file", "$file.pag", "$file.dir", "$file.db";