init
This commit is contained in:
46
vstorrent.pl
Executable file
46
vstorrent.pl
Executable file
@@ -0,0 +1,46 @@
|
||||
#!usr/bin/perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use Data::Dumper;
|
||||
use Path::Tiny qw(path);
|
||||
use MIME::Base64 qw(decode_base64);
|
||||
use open ':std', ':encoding(UTF-8)';
|
||||
|
||||
my $dir = './singleFile';
|
||||
my @files = glob ( "$dir/*.html" );
|
||||
&getImagesfromHTML();
|
||||
|
||||
sub getImagesfromHTML {
|
||||
&Delimiter((caller(0))[3]);
|
||||
|
||||
for my $i (0 .. $#files) {
|
||||
my $filename = $files[$i];
|
||||
my $content = path($filename)->slurp_utf8;
|
||||
$content =~ s/\R//g;
|
||||
|
||||
my $i = 0;
|
||||
while ($content =~ m/<div class=excerpt-thumb>(.+?)<\/div>/g) {
|
||||
$i++;
|
||||
my $dataset = $1;
|
||||
$dataset =~ m/title="(.+?)"/;
|
||||
my $title = $1;
|
||||
$title =~ s/Permalink to //;
|
||||
$dataset =~ m/src=(.+?) /;
|
||||
my $src = $1;
|
||||
$src =~ m/data:image\/(.+?)\;base64,/;
|
||||
my $filetype = $1;
|
||||
$src =~ s/data:image\/(.+?)\;base64,//;
|
||||
my $decoded= decode_base64($src);
|
||||
open my $fh, '>', "./images/$title.$filetype" or die $!;
|
||||
binmode $fh;
|
||||
print $fh $decoded;
|
||||
close $fh;
|
||||
print "Title: $title\nFiletype: $filetype\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub Delimiter {
|
||||
my $SubName = shift;
|
||||
print "\n" . "-" x 80 . "\nSUB " . $SubName . "\n" . '-' x 80 . "\n";
|
||||
}
|
||||
Reference in New Issue
Block a user