Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use warnings;
- use strict;
- use LWP::UserAgent;
- use HTTP::Request;
- my $lol = 0;
- my $mtd = 0;
- my $menu = 0;
- my $url = "";
- my $peti;
- my $resp;
- sub menu
- {
- if($menu == 0)
- {
- print "Metodo de peticion disponibles: ";
- print "\n [1] GET";
- print "\n [2] POST";
- print "\n [3] PUT";
- print "\nElije [1-3]: ";
- $menu = 1;
- }
- $mtd = <STDIN>;
- if(!($mtd =~ /[1-3]/))
- {
- print "[X] Error, debes elegir un numero de 1 a 3: ";
- &menu;
- }
- }
- sub url
- {
- print "URL: ";
- $url = <STDIN>;
- if(!($url =~ /^http:\/\//))
- {
- $url = "http://".$url;
- }
- }
- sub type
- {
- if($mtd == 1)
- {
- $peti = HTTP::Request->new(GET => $url);
- }
- elsif($mtd == 2)
- {
- $peti = HTTP::Request->new(POST => $url);
- }
- else
- {
- $peti = HTTP::Request->new(PUT => $url);
- }
- }
- sub conexion
- {
- print "\nEstableciendo conexion";
- my $nav = LWP::UserAgent->new();
- $nav->agent("Lolz 2.0.1 - Linux RedHat v1000");
- chomp $url;
- &type;
- $resp = $nav->request($peti);
- $resp = $resp->content();
- print "\nRespuesta desde servidor: [[$url]]";
- #print "\n\n".$resp;
- $lol = 1;
- }
- sub archivo
- {
- if($lol == 1)
- {
- print "\n\nEscribiendo datos en archivo...";
- open(FILE, ">archivo");
- print FILE $resp;
- close FILE;
- print "\n-_Fin_-";
- }
- }
- &menu;
- sleep(1);
- &url;&conexion;&archivo;
- print "\nBy kid_goth";
- print "\n";
- sleep(3);
Advertisement
Add Comment
Please, Sign In to add comment