#!/usr/bin/perl use strict; use warnings; my $tlUrl = "https://the-eye.eu/public/"; my %currentPageRef; my $pageNest; my $curl = `which curl`; chomp $curl; if ( $curl eq "" || ! defined $curl ) { print "No curl, exiting...\n"; exit 1; } sub dumpPage { my $page = shift; my @pageContent = split("\n", `$curl -s $page`); if ($page =~ m/public\/(.*)$/) { $pageNest = $1; } if ( $pageNest =~ m/\.\.\/$/ ) { # Need to lop off old nested dir $pageNest =~ s/\/([^\/]*\/\.\.\/)$//g; } if ( $pageNest !~ m/\/$/ ) { $pageNest .= "/"; } my $count = 0; foreach my $line (@pageContent) { if ($line =~ m/text\/javascript/ || $line =~ m/\/div/ || $line =~ m/\/i/ || $line =~ m/img\ src/ || $line =~ m/\/script/) { next; } #if ($line =~ m/\"(.*\/)\"\>(.*)\(.*)\/g; } print "$count : $name\n"; $currentPageRef{$count} = $link; $count++; } } } sub pageReturn { my $choice = shift; my $newPage = $tlUrl . $currentPageRef{$choice}; return $newPage; } sub download { my $link = shift; system("wget $link"); } sub printHelp { my $help = <; chomp $input; if ($input =~ m/download/) { my @inputs = split(" ", $input); my $dlLink = $currentPageRef{$inputs[1]}; $dlLink = $tlUrl . $dlLink; download($dlLink); next; } if ($input =~ m/file/) { my @inputs = split(" ", $input); my $queryLink = $currentPageRef{$inputs[1]}; $queryLink = $tlUrl . $queryLink; print "File is: $queryLink\n"; next; } if ($input =~ m/quit/||$input =~ /exit/) { print "Exiting..\n"; exit 0; } if ($input =~ m/search/) { my @inputs = split(" ", $input); shift(@inputs); my $searchTerm = join(" ", @inputs); #my $searchTerm = $inputs[1]; if ( $searchTerm =~ m/\"(.*)\"/ ) { $searchTerm = $1; $searchTerm =~ s/\ /%20/g; } foreach my $key ( keys %currentPageRef ) { if ( $currentPageRef{$key} =~ m/$searchTerm/i ) { my $printLine = $currentPageRef{$key}; $printLine =~ s/%20/\ /g; $printLine =~ s/%2C/,/g; $printLine =~ s/%26/&/g; print "$key : $printLine\n"; } } next; } my $newPage; if ($input eq "top") { $newPage = $tlUrl; } else { $newPage = pageReturn($input); #print "Your next request is: $newPage\n"; } %currentPageRef = (); dumpPage($newPage); }