Saturday, October 25, 2014

Retrieving source of web pages using LWP::Simple

A simple example to show how to fetch a web page source and display on the screen.
#!/usr/bin/perl

use LWP::Simple; # required module to retrieve the source of any web page

my $content = get("http://www.hisdates.com/index.html"); # retrieving the source of web page and storing in a variable

print $content; # display the web page source on the screen


Output:
-------
On running the Perl script from command line, the html source for the webpage "http://www.hisdates.com/index.html" will be displayed on the screen.