| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
3
|
|
|
3
|
|
3965
|
use strict; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
3844
|
|
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Net::ITE - OOP-ish interface to the Internet Topic Exchange |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Net::ITE; |
|
10
|
|
|
|
|
|
|
my $ite = Net::ITE->new(); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Get all the posts for a topic |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $topic = $ite->topic("montreal_quebec_canada"); |
|
15
|
|
|
|
|
|
|
my $posts = $topic->posts(); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
while (my $item = $posts->next()) { |
|
18
|
|
|
|
|
|
|
print $item->title()."\n"; |
|
19
|
|
|
|
|
|
|
print $item->excerpt()."\n"; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Add your post to a topic listing |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$topic->ping({title=>"foo", |
|
25
|
|
|
|
|
|
|
url=>"http://foo.com/123", |
|
26
|
|
|
|
|
|
|
excerpt=>"yadda yadda yadda"}); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Create a new topic |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$ite->new_topic("foobars"); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
OOP-ish interface to the Internet Topic Exchange. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 NOTES |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=over 4 |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item * |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
The error handling sucks and will be addressed in future releases. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=back |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
package Net::ITE; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$Net::ITE::VERSION = '0.05'; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 PACKAGE METHODS |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 __PACKAGE__->new($blogname) |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Returns an object.Woot! |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub new { |
|
63
|
3
|
|
|
3
|
|
11655
|
my $pkg = shift; |
|
64
|
3
|
|
|
|
|
8
|
my $blog = shift; |
|
65
|
3
|
|
|
|
|
14
|
return bless \$blog,$pkg; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 Net::ITE |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 $ite->topics() |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
When called in a scalar context, returns an I |
|
79
|
|
|
|
|
|
|
object of I objects. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
When called in an array context, returns a list of I |
|
82
|
|
|
|
|
|
|
objects. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub topics { |
|
87
|
1
|
|
|
1
|
|
678
|
my $self = shift; |
|
88
|
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
182
|
my $data = Net::ITE::Network->get(Net::ITE::Constants->TOPICS."rss"); |
|
90
|
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
0
|
if (! $data) { |
|
92
|
0
|
|
|
|
|
0
|
warn "Unable to topics.\n"; |
|
93
|
0
|
|
|
|
|
0
|
return undef; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
0
|
my $items = Parser->parse_feed($data); |
|
97
|
|
|
|
|
|
|
|
|
98
|
0
|
0
|
|
|
|
0
|
if (! $items) { |
|
99
|
0
|
|
|
|
|
0
|
warn "Unable to parse topics.\n"; |
|
100
|
0
|
|
|
|
|
0
|
return undef; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
0
|
map { $_ = {title=>$_->{title},blog=>$self} } @$items; |
|
|
0
|
|
|
|
|
0
|
|
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
return wantarray ? |
|
106
|
0
|
0
|
|
|
|
0
|
map { Net::ITE::Topic->new($_); } @$items : |
|
|
0
|
|
|
|
|
0
|
|
|
107
|
|
|
|
|
|
|
Net::ITE::Iterator->new("Net::ITE::Topic",$items); |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 $ite->topic($topic) |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Returns a I object. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub topic { |
|
117
|
2
|
|
|
2
|
|
1069
|
my $self = shift; |
|
118
|
2
|
|
|
|
|
27
|
return Net::ITE::Topic->new({title=>$_[0],blog=>$self}); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 $ite->new_topic($topic) |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Returns true or false. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub new_topic { |
|
128
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
|
129
|
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
0
|
my $post = Net::ITE::Network->post(Net::ITE::Constants->NEWTOPIC, |
|
131
|
|
|
|
|
|
|
{catname=>$_[0]}); |
|
132
|
|
|
|
|
|
|
|
|
133
|
0
|
0
|
|
|
|
0
|
if (! $post) { |
|
134
|
0
|
|
|
|
|
0
|
warn "There was a transport error trying to create new topic.\n"; |
|
135
|
0
|
|
|
|
|
0
|
return 0; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
0
|
0
|
|
|
|
0
|
if ($$post =~ /An error occurred<\/b>:(?:\s)+(.*)$/) { |
|
139
|
0
|
|
|
|
|
0
|
warn $1,"\n"; |
|
140
|
0
|
|
|
|
|
0
|
return 0; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
0
|
return 1; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 Net::ITE::Topic |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=cut |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
package Net::ITE::Topic; |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
my $tb = undef; |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub new { |
|
155
|
2
|
|
|
2
|
|
4
|
my $pkg = shift; |
|
156
|
2
|
|
|
|
|
8
|
return bless $_[0],$pkg; |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 $topic->title() |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=cut |
|
162
|
|
|
|
|
|
|
|
|
163
|
0
|
|
|
0
|
|
0
|
sub title { return shift->{title}; } |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 $topic->about() |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
I |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 $topic->url() |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub url { |
|
176
|
2
|
|
|
2
|
|
912
|
my $self = shift; |
|
177
|
2
|
|
|
|
|
419
|
return Net::ITE::Constants->TOPIC.$self->title()."/"; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head2 $topic->posts() |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
When called in a scalar context, returns an I |
|
183
|
|
|
|
|
|
|
object of I objects. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
When called in an array context, returns a list of I |
|
186
|
|
|
|
|
|
|
objects. |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub posts { |
|
191
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
192
|
|
|
|
|
|
|
|
|
193
|
0
|
|
|
|
|
|
my $data = Net::ITE::Network->get($self->url()."rss"); |
|
194
|
|
|
|
|
|
|
|
|
195
|
0
|
0
|
|
|
|
|
if (! $data) { |
|
196
|
0
|
|
|
|
|
|
warn "Unable to retrieve posts for topic.\n"; |
|
197
|
0
|
|
|
|
|
|
return undef; |
|
198
|
|
|
|
|
|
|
} |
|
199
|
|
|
|
|
|
|
|
|
200
|
0
|
|
|
|
|
|
my $posts = Parser->parse_feed($data); |
|
201
|
|
|
|
|
|
|
|
|
202
|
0
|
0
|
|
|
|
|
if (! $posts) { |
|
203
|
0
|
|
|
|
|
|
warn "Unable to parse posts for topic.\n"; |
|
204
|
0
|
|
|
|
|
|
return undef; |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
return wantarray ? |
|
208
|
0
|
0
|
|
|
|
|
map { Net::ITE::Post->new($_); } @$posts : |
|
|
0
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Net::ITE::Iterator->new("Net::ITE::Post",$posts); |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head2 $topic->ping(\%args) |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=over 4 |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=item * |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
B |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
If this property is not passed then the value passed to the I |
|
221
|
|
|
|
|
|
|
constructor will be used. |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=item * |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
B |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=item * |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
B |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=item * |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
B |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=back |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
Returns true or false. |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=cut |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
sub ping { |
|
242
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
243
|
0
|
|
|
|
|
|
my $data = shift; |
|
244
|
|
|
|
|
|
|
|
|
245
|
0
|
|
|
|
|
|
$data->{ping_url} = $self->url(); |
|
246
|
0
|
|
0
|
|
|
|
$data->{blog_name} ||= ${$self->{blog}}; |
|
|
0
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
|
|
248
|
0
|
0
|
|
|
|
|
if (! $tb) { |
|
249
|
0
|
|
|
|
|
|
require Net::TrackBack; |
|
250
|
0
|
|
|
|
|
|
$tb = Net::TrackBack->new(); |
|
251
|
|
|
|
|
|
|
} |
|
252
|
|
|
|
|
|
|
|
|
253
|
0
|
|
|
|
|
|
$tb->send_ping($data); |
|
254
|
|
|
|
|
|
|
|
|
255
|
0
|
0
|
|
|
|
|
if (! $tb->is_success()) { |
|
256
|
0
|
|
|
|
|
|
warn $tb->message(); |
|
257
|
0
|
|
|
|
|
|
return 0; |
|
258
|
|
|
|
|
|
|
} |
|
259
|
|
|
|
|
|
|
|
|
260
|
0
|
|
|
|
|
|
return 1; |
|
261
|
|
|
|
|
|
|
} |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=head1 Net::ITE::Post |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=cut |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
package Net::ITE::Post; |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
sub new { |
|
270
|
0
|
|
|
0
|
|
|
my $pkg = shift; |
|
271
|
0
|
|
|
|
|
|
return bless $_[0],$pkg; |
|
272
|
|
|
|
|
|
|
} |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=head2 $post->title() |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=cut |
|
277
|
|
|
|
|
|
|
|
|
278
|
0
|
|
|
0
|
|
|
sub title { return shift->{title} } |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=head2 $post->url() |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=cut |
|
283
|
|
|
|
|
|
|
|
|
284
|
0
|
|
|
0
|
|
|
sub url { return shift->{link}; } |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=head2 $post->excerpt() |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=cut |
|
289
|
|
|
|
|
|
|
|
|
290
|
0
|
|
|
0
|
|
|
sub excerpt { return shift->{description}; } |
|
291
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
=head1 Net::ITE::Iterator |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=cut |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
package Net::ITE::Iterator; |
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
sub new { |
|
299
|
0
|
|
|
0
|
|
|
my $pkg = shift; |
|
300
|
0
|
|
|
|
|
|
return bless {pkg=>$_[0],data=>$_[1],count=>0}, $pkg; |
|
301
|
|
|
|
|
|
|
} |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=head2 $it->count() |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=cut |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
sub count { |
|
308
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
309
|
0
|
|
|
|
|
|
return scalar @{$self->{data}}; |
|
|
0
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
} |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
=head2 $it->next() |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
Returns an object.Woot! |
|
315
|
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
=cut |
|
317
|
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
sub next { |
|
319
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
320
|
0
|
0
|
|
|
|
|
if (my $data = $self->{data}->[$self->{count}++]) { |
|
321
|
0
|
|
|
|
|
|
return $self->{pkg}->new($data); |
|
322
|
|
|
|
|
|
|
} |
|
323
|
|
|
|
|
|
|
} |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
package Net::ITE::Network; |
|
326
|
|
|
|
|
|
|
my $ua = undef; |
|
327
|
|
|
|
|
|
|
|
|
328
|
3
|
|
|
3
|
|
3424
|
use HTTP::Request; |
|
|
3
|
|
|
|
|
88946
|
|
|
|
3
|
|
|
|
|
1106
|
|
|
329
|
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
sub get { |
|
331
|
0
|
|
|
0
|
|
|
my $pkg = shift; |
|
332
|
0
|
|
|
|
|
|
return &send_request(HTTP::Request->new(GET=>$_[0])); |
|
333
|
|
|
|
|
|
|
} |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
sub post { |
|
336
|
0
|
|
|
0
|
|
|
my $pkg = shift; |
|
337
|
0
|
|
|
|
|
|
my $uri = shift; |
|
338
|
0
|
|
|
|
|
|
my $args = shift; |
|
339
|
|
|
|
|
|
|
|
|
340
|
0
|
|
|
|
|
|
my @params = (); |
|
341
|
|
|
|
|
|
|
|
|
342
|
0
|
|
|
|
|
|
foreach my $param (keys %$args) { |
|
343
|
0
|
|
|
|
|
|
my $value = $args->{$param}; |
|
344
|
0
|
|
|
|
|
|
$value =~ s!([^a-zA-Z0-9_.-])!uc sprintf "%%%02x", ord($1)!eg; |
|
|
0
|
|
|
|
|
|
|
|
345
|
0
|
|
|
|
|
|
push @params,"$param=$value"; |
|
346
|
|
|
|
|
|
|
} |
|
347
|
|
|
|
|
|
|
|
|
348
|
0
|
|
|
|
|
|
my $req = HTTP::Request->new(POST =>$uri); |
|
349
|
0
|
|
|
|
|
|
$req->content_type('application/x-www-form-urlencoded'); |
|
350
|
0
|
|
|
|
|
|
$req->content(join('&',@params)); |
|
351
|
|
|
|
|
|
|
|
|
352
|
0
|
|
|
|
|
|
return &send_request($req); |
|
353
|
|
|
|
|
|
|
} |
|
354
|
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
sub ua { |
|
356
|
0
|
0
|
|
0
|
|
|
if (! $ua) { |
|
357
|
0
|
|
|
|
|
|
require LWP::UserAgent; |
|
358
|
0
|
|
|
|
|
|
$ua = LWP::UserAgent->new(); |
|
359
|
|
|
|
|
|
|
} |
|
360
|
|
|
|
|
|
|
|
|
361
|
0
|
|
|
|
|
|
return $ua; |
|
362
|
|
|
|
|
|
|
} |
|
363
|
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
sub send_request { |
|
365
|
0
|
|
|
0
|
|
|
my $res = &ua()->request($_[0]); |
|
366
|
|
|
|
|
|
|
|
|
367
|
0
|
0
|
|
|
|
|
if (! $res->is_success()) { |
|
368
|
0
|
|
|
|
|
|
warn "Failed to retrieve data, ".$res->message()."\n"; |
|
369
|
0
|
|
|
|
|
|
return undef; |
|
370
|
|
|
|
|
|
|
} |
|
371
|
|
|
|
|
|
|
|
|
372
|
0
|
|
|
|
|
|
return $res->content_ref(); |
|
373
|
|
|
|
|
|
|
} |
|
374
|
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
package Parser; |
|
376
|
3
|
|
|
3
|
|
1457
|
use XML::RSS; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
377
|
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
my $rss = undef; |
|
379
|
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
sub parse_feed { |
|
381
|
|
|
|
|
|
|
my $pkg = shift; |
|
382
|
|
|
|
|
|
|
my $sr_rss = shift; |
|
383
|
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
$rss ||= XML::RSS->new(); |
|
385
|
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
eval { $rss->parse($$sr_rss); }; |
|
387
|
|
|
|
|
|
|
if ($@) { |
|
388
|
|
|
|
|
|
|
warn $@,"\n"; |
|
389
|
|
|
|
|
|
|
return undef; |
|
390
|
|
|
|
|
|
|
} |
|
391
|
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
return $rss->{items}; |
|
393
|
|
|
|
|
|
|
} |
|
394
|
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
package Net::ITE::Constants; |
|
396
|
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
use constant ITE => "http://topicexchange.com"; |
|
398
|
|
|
|
|
|
|
use constant TOPICS => ITE."/topics/"; |
|
399
|
|
|
|
|
|
|
use constant TOPIC => ITE."/t/"; |
|
400
|
|
|
|
|
|
|
use constant NEWTOPIC => ITE."/new"; |
|
401
|
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
return 1; |
|
403
|
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
=head1 VERSION |
|
405
|
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
0.05 |
|
407
|
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
=head1 DATE |
|
409
|
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
$Date: 2003/03/20 05:09:14 $ |
|
411
|
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
=head1 AUTHOR |
|
413
|
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
Aaron Straup Cope |
|
415
|
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
417
|
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
http://topicexchange.com |
|
419
|
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
=head1 LICENSE |
|
421
|
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
Copyright (c) 2003 Aaron Straup Cope, All Rights Reserved. |
|
423
|
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
This is free software, you may use it and distribute it under the same |
|
425
|
|
|
|
|
|
|
terms as Perl itself. |
|
426
|
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
=cut |
|
428
|
|
|
|
|
|
|
|