Annotation of pandia/blacklist, revision 1.2
1.1 snw 1: #!/usr/bin/env perl
2:
3: #
1.2 ! snw 4: # $Id: blacklist,v 1.1 2025/06/27 16:20:30 snw Exp $
1.1 snw 5: # Copyright (C) 2025 Coherent Logic Development LLC
6: #
7: # Author: Serena Willis <snw@coherent-logic.com>
8: #
9: # Licensed AGPL-3.0
10: #
1.2 ! snw 11: # $Log: blacklist,v $
! 12: # Revision 1.1 2025/06/27 16:20:30 snw
! 13: # Add blacklist
! 14: #
1.1 snw 15: #
16:
17: use Getopt::Long;
1.2 ! snw 18: use DBI;
! 19:
! 20: my $dbh = "";
! 21: my $dsn = "";
! 22:
! 23: GetOptions("dbhost=s" => \$dbhost,
! 24: "dbname=s" => \$dbname,
! 25: "dbusername=s" => \$dbusername,
! 26: "dbpw=s" => \$dbpw,
! 27: "domain=s" => \$domain)
! 28: or die("error in command line arguments");
! 29:
! 30: $| = 1;
! 31: print "pandia blacklist v0.0.1\n";
! 32: print " Copyright (C) 2025 Coherent Logic Development LLC\n\n";
! 33:
! 34: print "pandia: connecting to $dbname database at $dbhost...";
! 35: $dsn = "DBI:mysql:database=$dbname;host=$dbhost;port=3306;mysql_connect_timeout=5;";
! 36: $dbh = DBI->connect($dsn, $dbusername, $dbpw, {RaiseError => 0, PrintError => 1});
! 37: die "pandia: failed to connect to MySQL database: DBI->errstr()" unless $dbh;
! 38: print "[OK]\n";
! 39:
! 40: print "pandia: blacklisting domain $domain...";
! 41: my $sth = $dbh->prepare("INSERT INTO blacklist (url_domain) VALUES (?)");
! 42: $sth->execute($domain);
! 43: print "[OK]\n";
! 44:
! 45: print "pandia: removing blacklisted items from crawl queue...";
! 46: my $sth = $dbh->prepare("DELETE crawl_queue FROM crawl_queue JOIN blacklist ON crawl_queue.url_domain=blacklist.url_domain");
! 47: $sth->execute();
! 48: print "[OK]\n";
! 49:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>