Thread alle files (.torrent) in ein Verz. kopieren (3 answers)
Opened by Gast at 2007-02-13 11:25

pacey
 2007-03-29 07:59
#9632 #9632
User since
2004-03-01
23 Artikel
BenutzerIn
[Homepage] [default_avatar]
Ich würde das so in etwa machen:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/perl

use LWP::UserAgent;
use HTML::LinkExtor;
use URI::URL;
use File::Basename;
my $adresse='http://xanpac.de';
my $agent = LWP::UserAgent->new;
my @torrents= ();

sub cb {
my($tag, %attr) = @_;
if ($tag ne 'a') {
return;
}
push(@torrents, values %attr);
}

$extractor = HTML::LinkExtor->new(\&cb);

$ergebnis = $agent->request(HTTP::Request->new(GET => $adresse),sub {$extractor->parse($_[0])});
$basis = $ergebnis->base;
@torrents = map {$_ = url($_, $base)->abs;} @torrents;

foreach (@torrents) {
if($_ =~ /\.torrent$/){

$dl = LWP::UserAgent->new;
$dl->timeout(50);

$antwort = $dl->get($adresse.$_);
$filename = fileparse($_);
if($antwort->is_success) {

open(FH, ">$filename") or die 'datei nicht schreibbar';
print FH $antwort->content;
close(FH);

}
}
}


Das ist zur Abwechslung sogar getestet :-)

pacey\n\n

<!--EDIT|pacey|1175140789-->
Quote
If You don't know what it does, why do you put it in your code

Code: ()
1
2
3
print +(a=>b=>c=>d=>e=>f=>g=>h=>i=>j=>k=>l=>m=>n=>o=>p=>q=>r=>s=>t=>u=>v=>w=>x=>y=>z=>" ")

[9=>20=>18=>19=>-1=>0=>13=>14=>19=>7=>4=>17=>-1=>15=>4=>17=>11=>-1=>7=>0=>2=>10=>4=>17];

View full thread alle files (.torrent) in ein Verz. kopieren