Tong Sun

NAME

News::Search - Usenet news searching toolkit

SYNOPSIS

  use News::Search;

  my $ns = News::Search->new();
  $ns->search_for(\@ARGV);

  my %newsarticles = $ns->SearchNewsgroups;

DESCRIPTION

News::Search searches Usenet news postings.

It can be used to search local news groups that google doesn't cover. Or, even for news groups that are covered by google, it can give you all the hits in one file, in the format that you prescribed.

You can also use the provided news-search in cron to watch specific news groups for specific criteria and mail you reports according to the interval you set.

METHODS

News::Search->new(\%config_param)

Initialize the object.

  my $searcher = News::Search->new();

or,

  my $searcher = News::Search->new( {} );

which are the same as:

  my $searcher = News::Search->new( {
     nntp_server => 'news',
     msg_headers => 'Date|From',        # + Subject, which is always printed
     msg_limit   => 200,
     verbose     => 0,
     on_group    => \&default_group_handler,
     on_message  => \&default_message_handler,
  } );

What shown above are default settings. Any of the %config_param attribute can be omitted when calling the new method.

The new is the only class method. All the rest methods are object methods.

Object attributes

The following object attributes are accessible.

  • nntp_server([set_val])

    The nntp server to search.

  • msg_headers([set_val])

    Message headers to print.

  • msg_limit([set_val])

    Maximum number of posts to search (not return).

  • verbose([set_val])

    Be verbose.

  • on_group([set_val])

    Handler for group starts. Refer to news-search for the example.

  • on_message([set_val])

    Handler for news message. Refer to news-search for the example.

Provide the set_val to change the attribute, omitting it to retrieve the attribute value. E.g.,

  $searcher->nntp_server("news.easysw.com");

Object method: search_for($array_ref)

  $searcher->search_for(\@ARGV);

Command line parameter handling. Refer to news-search section "command line arguments" for details.

Object method: SearchNewsgroups()

Search the given newsgroups with the given criteria:

  my %newsarticles = $ns->SearchNewsgroups;

  foreach my $article (values %newsarticles) {
    # deal with  $article->{"SUBJECT"}, @{$article->{"HEADER"}})
    #  and $article->{"BODY"}
  }

Refer to news-search for usage example.

SEE ALSO

Net::NNTP.

BUGS

Please report any bugs or feature requests to bug-news-search at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=News-Search. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc News::Search

You can also look for information at:

AUTHOR

SUN, Tong <suntong at cpan.org> http://xpt.sourceforge.net/

COPYRIGHT

Copyright 2003-2008 Tong Sun, all rights reserved.

This program is released under the BSD license.