🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
12 messages
12 total messages Started by sebhoff2002 Mon, 23 May 2005 09:23
simple Perl script needed
#71670
Author: sebhoff2002
Date: Mon, 23 May 2005 09:23
25 lines
2334 bytes
Hi,
I've been browsing CPAN and other sources for something which I expect
to be pretty simple/standard - but I have been a bit overwhelmed by
what's available and since I'm not a (real) programmer, I'm also a bit
lost as to how to implement a solution. I found lots of modules and I'm
sure they can do what I want to do - but what I would really need is a
sample script that uses the "best" method. Once I have this, I can
learn and extend the functionality according to my needs. ;-)

I'm looking for a simple Perl script that connects to a NNTP-server
(with authentication) and downloads all xover headers of a list of
newsgroups to a local disk. Ideally, this would be fast (probably
depends on the server software...) and the output should be in a format
that can be easily post-processed (but the format is not a major
concern).

Secondly, does anybody know of any software/Perl-script that
consistently tracks which elements of postings are quoted from previous
ones? I'm a linguist and for my research, I need to be able to
determine exactly which elements of a previous message are referred
to....

Thanks for any kind of input!
Sebastian
Re: simple Perl script needed
#71672
Author: Ted S.
Date: Mon, 23 May 2005 13:59
19 lines
1832 bytes
Somebody claiming to be sebhoff2002@yahoo.com wrote in 
news:1116840238.189967.41700@o13g2000cwo.googlegroups.com:

> I'm looking for a simple Perl script that connects to a NNTP-server
> (with authentication) and downloads all xover headers of a list of
> newsgroups to a local disk. Ideally, this would be fast (probably
> depends on the server software...) and the output should be in a format
> that can be easily post-processed (but the format is not a major
> concern).

You may wish to try asking on a Perl group , or a mailing list like the 
ones at Active State. <http://listserv.ActiveState.com/mailman/mysubs> is 
the URL for managing subscriptions, but you may have to register first.

-- 
Ted <fedya at bestweb dot net>
TV Announcer: It's 11:00.  Do you know where your children are?
Homer: I told you last night, *no*!
<http://www.snpp.com/episodes/4F06.html>
Re: simple Perl script needed
#71673
Author: SINNER
Date: Mon, 23 May 2005 15:46
12 lines
1607 bytes
*  Wrote in news.software.readers:

> I'm looking for a simple Perl script that connects to a NNTP-server
> (with authentication) and downloads all xover headers of a list of
> newsgroups to a local disk.

Leafnode, while not a perl script can accomplish this piece of what you 
need. You are posting from Google and dont mention an OS, Leafnode runs 
on *nix.

-- 
David
Re: simple Perl script needed
#71675
Author: Tim Skirvin
Date: Mon, 23 May 2005 17:36
19 lines
2078 bytes
sebhoff2002@yahoo.com writes:

>I'm looking for a simple Perl script that connects to a NNTP-server
>(with authentication) and downloads all xover headers of a list of
>newsgroups to a local disk. Ideally, this would be fast (probably
>depends on the server software...) and the output should be in a format
>that can be easily post-processed (but the format is not a major
>concern).

        http://www.killfile.org/~tskirvin/software/news/kiboze/

        That actually gets all of the articles, period, but it could be
modified pretty easily and cleanly.


			   - Tim Skirvin (tskirvin@killfile.org)
-- 
http://www.killfile.org/~tskirvin/  Skirv's Homepage <FISH>< <*>
http://www.killfile.org/~tskirvin/posts.html	   Skirv's Posts
Re: simple Perl script needed
#71679
Author: sebhoff2002
Date: Tue, 24 May 2005 06:53
7 lines
1575 bytes
Yes - I had already tried this. But it's very slow to retrieve
everything - because of the news server... What I need now is something
that just gets the headers - quick. ;-) Will look into it and see how I
can change the script.
Thanks for your reply!
Sebastian
Re: simple Perl script needed
#71680
Author: Szymon Sokół
Date: Tue, 24 May 2005 07:49
39 lines
2977 bytes
In news.software.nntp sebhoff2002@yahoo.com wrote:
> Yes - I had already tried this. But it's very slow to retrieve
> everything - because of the news server... What I need now is something
> that just gets the headers - quick. ;-) Will look into it and see how I
> can change the script.
Well, if you need something simple, short and fast (but not tested very
thoroughly and without any error handling...):

#!/usr/bin/perl -w
use Net::NNTP; 
# customize these 3 lines according to your needs
my $output = "/directory/where/output/goes/";
my $nntpserver = "news.somedomain.com";
my @groups = ("news.software.nntp", "news.software.readers");

my $nntp = Net::NNTP->new($nntpserver);
$| = 1;
for my $group (@groups) {
  my $file;
  open $file, ">${output}/$group";
  my $all = $nntp->listgroup($group);
  my $total = scalar @$all;
  printf "Group $group, total of %d messages\n", $total;
  my $j = 1;
  for my $msg (@$all) {
    printf "Getting #%d of %d message headers\r", $j++, $total;
    $nntp->head($msg,$file);
    print $file "\n"; # an empty line separates headers
  }
  close $file;
  print "\n";
}
$nntp->quit;

-- 
Szymon Sokół (SS316-RIPE) -- Network Manager                                B
Computer Center, AGH - University of Science and Technology, Cracow, Poland O
http://home.agh.edu.pl/szymon/ PGP key id: RSA: 0x2ABE016B, DSS: 0xF9289982 F 
Free speech includes the right not to listen, if not interested -- Heinlein H
Re: simple Perl script needed
#71681
Author: Blinky the Shark
Date: Tue, 24 May 2005 08:01
41 lines
2747 bytes
Szymon Sokó³ wrote:
> In news.software.nntp sebhoff2002@yahoo.com wrote:
>> Yes - I had already tried this. But it's very slow to retrieve
>> everything - because of the news server... What I need now is something
>> that just gets the headers - quick. ;-) Will look into it and see how I
>> can change the script.
> Well, if you need something simple, short and fast (but not tested very
> thoroughly and without any error handling...):

> #!/usr/bin/perl -w
> use Net::NNTP; 
> # customize these 3 lines according to your needs
> my $output = "/directory/where/output/goes/";
> my $nntpserver = "news.somedomain.com";
> my @groups = ("news.software.nntp", "news.software.readers");

> my $nntp = Net::NNTP->new($nntpserver);
> $| = 1;
> for my $group (@groups) {
>   my $file;
>   open $file, ">${output}/$group";
>   my $all = $nntp->listgroup($group);
>   my $total = scalar @$all;
>   printf "Group $group, total of %d messages\n", $total;
>   my $j = 1;
>   for my $msg (@$all) {
>     printf "Getting #%d of %d message headers\r", $j++, $total;
>     $nntp->head($msg,$file);
>     print $file "\n"; # an empty line separates headers
>   }
>   close $file;
>   print "\n";
> }
> $nntp->quit;

Where does the authentication take place?

-- 
Blinky         Linux Registered User 297263
Killing all Usenet posts from Google Groups
Info:   http://blinkynet.net/comp/uip5.html
Re: simple Perl script needed
#71683
Author: sebhoff2002
Date: Tue, 24 May 2005 09:23
20 lines
2349 bytes
Many thanks for this! It works - BUT: It is much slower than what I
need.
If I use a newsreader like MT-NewsWatcher, the XOVER headers are
retrieved very quickly (thousands per minute). Your script on the other
hand sends individual commands to retrieve headers one by one.
In the meantime, I've been playing with Net::NNTP, but I'm stuck
because I don't know enough about references in Perl (one of the things
I have always successfully managed to put off learning...).

I think the extension methods mentioned at
http://search.cpan.org/~gbarr/libnet-1.19/Net/NNTP.pm would do the
trick for me - xover (MESSAGE-SPEC) and overview_fmt () - but
dereferencing the output is beyond me, I'm afraid. ;-) ("The return
value will be a reference to a hash where the keys are the message
numbers and each value contains the text of the requested header for
that message.") I'm hoping to get some help from a colleague tomorrow
who has more advanced programming skills...

Sebastian
Re: simple Perl script needed
#71684
Author: Szymon Sokół
Date: Tue, 24 May 2005 10:15
65 lines
3994 bytes
sebhoff2002@yahoo.com wrote:
> If I use a newsreader like MT-NewsWatcher, the XOVER headers are
> retrieved very quickly (thousands per minute). Your script on the other
> hand sends individual commands to retrieve headers one by one.
[----]
> I think the extension methods mentioned at
> http://search.cpan.org/~gbarr/libnet-1.19/Net/NNTP.pm would do the
> trick for me - xover (MESSAGE-SPEC) and overview_fmt () - but
> dereferencing the output is beyond me, I'm afraid. ;-)

I haven't thought of using xover, since not all servers handle NNTP
extensions (NEWNEWS, for example, is turned off on many server). 

Besides, I thought that you actually want ALL of the headers -  XOVER
returns only the headers that are put into the overview record, and overview
does not contain all headers, but only those listed in overview.fmt
(in the case of INN); typically those would be:
Subject: From: Date: Message-ID: References: Bytes: Lines: Xref:
but, for example, Path: or NNTP-Posting-Host: would not.

If you are sure that is OK for you, try this:

#!/usr/bin/perl -w
use Net::NNTP;
use strict;

# customize these lines according to your needs
my $output = "directory/";
my $nntpserver = "news.something.com";
my $user = "username";
my $pass = "password";
my @groups = ("news.software.nntp", "news.software.readers");

my $nntp = Net::NNTP->new($nntpserver);
$nntp->authinfo($user, $pass);
for my $group (@groups) {
  my $file;
  open $file, ">${output}/$group";
  my ($total, $first, $last) = $nntp->group($group);
  printf "Getting %d message headers from %s\n", $total, $group;
  my $xover = $nntp->xover([$first,$last]);
  my $fields = $nntp->overview_fmt();
  for my $msgid (keys %$xover) {
    my $hdrs = $xover->{$msgid};
    for my $fieldnum (0..$#$fields) {
      if($fields->[$fieldnum] =~ /:full$/o) {
        # some fields in overview include the field name...
        print $file $hdrs->[$fieldnum], "\n";
      } else {
        # ...but some do not
        print $file $fields->[$fieldnum], " ", $hdrs->[$fieldnum], "\n";
      }
    }
    print $file "\n"; # an empty line separates headers
  }
  close $file;
}


(yes, I have a terribly boring day at work ;-) )
-- 
Szymon Sokół (SS316-RIPE) -- Network Manager                                B
Computer Center, AGH - University of Science and Technology, Cracow, Poland O
http://home.agh.edu.pl/szymon/ PGP key id: RSA: 0x2ABE016B, DSS: 0xF9289982 F 
Free speech includes the right not to listen, if not interested -- Heinlein H
Re: simple Perl script needed
#71685
Author: sebhoff2002
Date: Tue, 24 May 2005 11:15
14 lines
2070 bytes
Wow - thanks a lot!!! You've just made my day! This is just what I
needed. I had tried out something similar but got stuck at "for my
$fieldnum (0..$#$fields) { ". ;-)

Am I right in assuming that there is no similarly fast way to download
lots of (complete) messages to your computer? I didn't find anything in
this direction and since MT-NewsWatcher and others also appear to
download articles on a one-by-one basis, I guess that's what I will
have to live with.

Again, thanks a lot for your help with this - please consider this
reply a virtual crate of beer. ;-)
Sebastian
Re: simple Perl script needed
#71690
Author: Andrew - Supernews
Date: Wed, 25 May 2005 04:48
10 lines
1636 bytes
On 2005-05-24, Szymon Sokó³ <szymon@bastard.operator.from.hell.pl> wrote:
> I haven't thought of using xover, since not all servers handle NNTP
> extensions (NEWNEWS, for example, is turned off on many server). 

xover isn't really optional in practice; most non-archaic clients will
simply fail if it isn't supported.

-- 
Andrew, Supernews
http://www.supernews.com - individual and corporate NNTP services
Re: simple Perl script needed
#71691
Author: Russ Allbery
Date: Wed, 25 May 2005 05:02
22 lines
2396 bytes
Andrew - Supernews <andrew+nonews@supernews.com> writes:
> On 2005-05-24, Szymon Sokó³ <szymon@bastard.operator.from.hell.pl> wrote:

>> I haven't thought of using xover, since not all servers handle NNTP
>> extensions (NEWNEWS, for example, is turned off on many server). 

> xover isn't really optional in practice; most non-archaic clients will
> simply fail if it isn't supported.

The other amusing bit is that NEWNEWS isn't an extension, but rather is in
theory a mandatory aspect of the protocol (although RFC 2980 has some
other bits to say about that).

The upcoming NNTP standard cleans this all up a lot, in part by
approaching things from less the direction of extensions and more from the
direction of capabilities.

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads