Wednesday, November 23, 2022

Storing the source code of a webpage in a variable using lwp and perl

use strict;
use warnings;
use LWP::Simple;
sub main{
print "Downloading ... \n";
#print get("http://www.google.com/");
#getstore("http://www.google.com","./source.code.html");
#to receive the response just as string we need to use single quote
#getstore('https://en.wikipedia.org/wiki/Main_Page#/media/File:Kathryn_Sullivan,_PCAST_Member_(cropped).jpg','face.jpg'>
my $code=getstore('https://en.wikipedia.org/wiki/Main_Page#/media/File:Kathryn_Sullivan,_PCAST_Member_(cropped).jpg','f>if($code==200)
{
print "Success\n";
}
else{
print "Failed\n";
}


print "Finished\n";
}
main();

No comments:

Post a Comment