line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Groups.pm,v 1.18 2004/01/03 19:09:42 cvspub Exp $ |
2
|
|
|
|
|
|
|
package WWW::Google::Groups; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
37602
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
82
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.09'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
7
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
68
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
534
|
use WWW::Google::Groups::NewsGroup; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
10
|
1
|
|
|
1
|
|
6
|
use WWW::Google::Groups::Vars; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
86
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
711
|
use WWW::Google::Groups::Search; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
13
|
|
|
|
|
|
|
our @ISA = qw(WWW::Google::Groups::Search); |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
6
|
use WWW::Mechanize; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
244
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
19
|
|
|
|
|
|
|
sub new { |
20
|
1
|
|
|
1
|
0
|
430
|
my $pkg = shift; |
21
|
1
|
|
|
|
|
6
|
my %arg = @_; |
22
|
1
|
|
|
|
|
3
|
foreach my $key (qw(server proxy)){ |
23
|
2
|
100
|
|
|
|
10
|
next unless $arg{$key}; |
24
|
1
|
50
|
|
|
|
10
|
$arg{$key} = 'http://'.$arg{$key} if $arg{$key} !~ m,^\w+?://,o; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
13
|
my $a = new WWW::Mechanize onwarn => undef, onerror => undef; |
28
|
1
|
50
|
|
|
|
20554
|
$a->proxy(['http'], $arg{proxy}) if $arg{proxy}; |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
50
|
|
|
21
|
bless { |
31
|
|
|
|
|
|
|
_server => ($arg{server} || 'http://groups.google.com/'), |
32
|
|
|
|
|
|
|
_proxy => $arg{proxy}, |
33
|
|
|
|
|
|
|
_agent => $a, |
34
|
|
|
|
|
|
|
}, $pkg; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
38
|
0
|
|
|
0
|
0
|
|
sub select_group($$) { new WWW::Google::Groups::NewsGroup(@_) } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
42
|
1
|
|
|
1
|
|
849
|
use Date::Parse; |
|
1
|
|
|
|
|
5176
|
|
|
1
|
|
|
|
|
769
|
|
43
|
|
|
|
|
|
|
sub save2mbox { |
44
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
45
|
0
|
|
|
|
|
|
my %arg = @_; |
46
|
0
|
|
|
|
|
|
my $article_count = 0; |
47
|
0
|
|
|
|
|
|
my $thread_count = 0; |
48
|
0
|
|
|
|
|
|
my $max_article_count = $arg{max_article_count}; |
49
|
0
|
|
|
|
|
|
my $max_thread_count = $arg{max_thread_count}; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $group = $self->select_group($arg{group}); |
52
|
0
|
|
|
|
|
|
$group->starting_thread($arg{starting_thread}); |
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
open F, '>', $arg{target_mbox} or die "Cannot create mbox $arg{target_mbox}"; |
55
|
|
|
|
|
|
|
MIRROR: |
56
|
0
|
|
|
|
|
|
while( my $thread = $group->next_thread() ){ |
57
|
0
|
|
|
|
|
|
while( my $article = $thread->next_article() ){ |
58
|
|
|
|
|
|
|
# print join q/ /, map{$article->header($_)} qw(From Date Subject); |
59
|
|
|
|
|
|
|
# print $/; |
60
|
0
|
|
|
|
|
|
my $email; |
61
|
0
|
|
|
|
|
|
$article->header("From")=~ /\s*(?:[<\(])(.+?@.+?)(?:[>\)])\s*/; |
62
|
0
|
0
|
|
|
|
|
unless($1){ |
63
|
0
|
|
|
|
|
|
$article->header("From")=~ /\s*(.+?@.+?)\s/o; |
64
|
0
|
|
|
|
|
|
$email = $1; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
else { |
67
|
0
|
|
|
|
|
|
$email = $1; |
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
|
my $date = scalar localtime str2time($article->header("Date")); |
70
|
0
|
|
|
|
|
|
my $content = $article->as_string; |
71
|
0
|
|
|
|
|
|
$content = "From $email $date\n".$content; |
72
|
0
|
|
|
|
|
|
print F $content; |
73
|
0
|
|
|
|
|
|
$article_count++; |
74
|
|
|
|
|
|
|
last MIRROR if |
75
|
0
|
0
|
0
|
|
|
|
defined($max_article_count) and |
76
|
|
|
|
|
|
|
$article_count >= $max_article_count; |
77
|
|
|
|
|
|
|
} |
78
|
0
|
|
|
|
|
|
$thread_count++; |
79
|
|
|
|
|
|
|
last MIRROR if |
80
|
0
|
0
|
0
|
|
|
|
defined($max_thread_count) and |
81
|
|
|
|
|
|
|
$thread_count >= $max_thread_count; |
82
|
|
|
|
|
|
|
} |
83
|
0
|
|
|
|
|
|
close F; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
88
|
|
|
|
|
|
|
sub post { |
89
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
90
|
0
|
|
|
|
|
|
my %arg = @_; |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
$self->{_agent}->get("http://posting.google.com/post?cmd=post&enc=ISO-8859-1&group=$arg{group}&gs=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26group%3D$arg{group}"); |
93
|
0
|
0
|
|
|
|
|
return unless $self->{_agent}->success(); |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
$self->{_agent}->submit_form( |
96
|
|
|
|
|
|
|
form_number => 1, |
97
|
|
|
|
|
|
|
fields => { |
98
|
|
|
|
|
|
|
Email => $arg{email}, |
99
|
|
|
|
|
|
|
Passwd => $arg{passwd}, |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
); |
102
|
0
|
0
|
|
|
|
|
return unless $self->{_agent}->success(); |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
$self->{_agent}->content=~/location\.replace\("(.+?)"\)/o; |
105
|
0
|
|
|
|
|
|
$self->{_agent}->get("$1"); |
106
|
0
|
0
|
|
|
|
|
return unless $self->{_agent}->success(); |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
$self->{_agent}->submit_form( |
109
|
|
|
|
|
|
|
form_number => 1, |
110
|
|
|
|
|
|
|
fields => { |
111
|
|
|
|
|
|
|
group => $arg{group}, |
112
|
|
|
|
|
|
|
subject => $arg{subject}, |
113
|
|
|
|
|
|
|
body => $arg{message}, |
114
|
|
|
|
|
|
|
}, |
115
|
|
|
|
|
|
|
button => 'actYes', |
116
|
|
|
|
|
|
|
); |
117
|
0
|
0
|
|
|
|
|
return unless $self->{_agent}->success(); |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
$self->{_agent}->follow_link( text_regex => qr/Sign out/i ); |
120
|
0
|
|
|
|
|
|
1; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |
125
|
|
|
|
|
|
|
__END__ |