rimbaud1964
Programmer
hello all,
g day dear folks at this forum at TEK-tips. well it took me more than 20 minutes to sign up but finally i am happy.
Now my question is - can i apply the code on the part of the board. i am pretty new to perl - and i want to solve some tasks that have to do with my current work on a study. There fore in need a spider -that runs against a forum
In order to get a "Copy" of the board with category 17 and category
3 .... see here
==readers from here i look forward to hear from you
, this is a super: this is obviously a great idea that is written here. Now my question is -
can i apply the code on the part of the board. In order to get
a "Copy" of the board with category 17 and category 3 ....
==Can this be done with the code written above?!
well i am very happy,
the demonstration is very imressive - and makes me thinking that Perl is very very powerful.
I will try to harvest this category of the Forum (note those both categories are of my
interest nothing more:
==
i want to discuss a little change here. The minimal change consists of changing
to
As i want to show, i change the use of the global variable @links.
We're forced to provide and initialize a variable that should be local to get_threads. Here's the fix:
Discussion:
with that changes i am able to run the code agains the full category.
==
Question - am i able to get the results of the above mentionde forum categories - and can i get the forum threads that are stored in the two above forums.... i love to hear from you. And all the other readers from here] i look forward to hear from you
Guess taht i need subroutines. i really look forward to hear from you
regards
g day dear folks at this forum at TEK-tips. well it took me more than 20 minutes to sign up but finally i am happy.
Now my question is - can i apply the code on the part of the board. i am pretty new to perl - and i want to solve some tasks that have to do with my current work on a study. There fore in need a spider -that runs against a forum
In order to get a "Copy" of the board with category 17 and category
3 .... see here
==readers from here i look forward to hear from you
, this is a super: this is obviously a great idea that is written here. Now my question is -
can i apply the code on the part of the board. In order to get
a "Copy" of the board with category 17 and category 3 ....
==Can this be done with the code written above?!
well i am very happy,
the demonstration is very imressive - and makes me thinking that Perl is very very powerful.
I will try to harvest this category of the Forum (note those both categories are of my
interest nothing more:
==
i want to discuss a little change here. The minimal change consists of changing
Code:
my $url = "[URL unfurl="true"]http://www.nukeforums.com/forums/viewforum.php?f=17";[/URL]
my $ua = LWP::RobotUA->new;
my $lp = HTML::LinkExtor->new(\&wanted_links);
my @links;
get_threads($url);
foreach my $page (@links) {
...
}
Code:
my $ua = LWP::RobotUA->new;
my $lp = HTML::LinkExtor->new(\&wanted_links);
my @links;
foreach my $forum_id (17, 3) {
my $url = "[URL unfurl="true"]http://www.nukeforums.com/forums/viewforum.php?f=$forum[/URL]
+_id";
@links = (); # yuck!
my $links = get_threads($url);
foreach my $page (@$links) {
...
}
}
We're forced to provide and initialize a variable that should be local to get_threads. Here's the fix:
Code:
#!/usr/bin/perl
use strict;
use warnings;
use LWP::RobotUA;
use HTML::LinkExtor;
use HTML::TokeParser;
use URI::URL;
use Data::Dumper; # for show and troubleshooting
my $ua = LWP::RobotUA->new();
foreach my $forum_id (17, 3) {
my $url = "[URL unfurl="true"]http://www.nukeforums.com/forums/viewforum.php?f=$forum[/URL]
+_id";
my $links = get_threads($url);
foreach my $page (@$links) {
...
}
}
sub get_thread {
...
}
sub get_threads {
my $page = shift;
my @links;
my $lp = HTML::LinkExtor->new(sub {
my($tag, %attr) = @_;
return unless exists $attr{'href'};
return if $attr{'href'} !~ /^viewtopic\.php\?t=/;
push @links, values %attr;
});
my $request = HTTP::Request->new(GET => $url);
my $response = $ua->request($request, sub {$lp->parse($_[0])});
# Expand URLs to absolute ones
my $base = $response->base;
return [ map { url($_, $base)->abs } @links ];
with that changes i am able to run the code agains the full category.
==
Question - am i able to get the results of the above mentionde forum categories - and can i get the forum threads that are stored in the two above forums.... i love to hear from you. And all the other readers from here] i look forward to hear from you
Guess taht i need subroutines. i really look forward to hear from you
regards