Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I want to automate download web page from browser.After downloading web page .My download web page will be same as how browser is showing web page.I can download web page ,but It does not contain images.whether is it possible in Perl.

Could you give any idea for that

Regards,

Senthil

  • Comment on Download Webpage as how browser is showing a webpage

Replies are listed 'Best First'.
Re: Download Webpage as how browser is showing a webpage
by Corion (Patriarch) on Oct 14, 2011 at 07:59 UTC

    Just download all linked images too, and all CSS files. See WWW::Mechanize->images.

Re: Download Webpage as how browser is showing a webpage
by Gangabass (Vicar) on Oct 14, 2011 at 08:04 UTC

    I have found this code in the WWW::Mechanize::Firefox documentation:

    Fetch a page to a file with all images
    use WWW::Mechanize::Firefox; my $mech = WWW::Mechanize::Firefox->new( tab => 'current', ); $mech->get('http://google.com'); $mech->save_content('google_com.html', 'google_com files');

      Hi Gangabass

      I executed that program.I am not getting as same browser shows .In download fie images are missing

      Any idea?

        what are you getting when you run it (any error messages)? Did you have any problems installing WWW::Mechanize::Firefox? Do you have the Mozrepl plugin for firefox? You need to install that to communicate with firefox.
Re: Download Webpage as how browser is showing a webpage
by tospo (Hermit) on Oct 14, 2011 at 07:59 UTC
    If you want to download an entire web-page with all the images and you are on UNIX/Linux then I recommend using "wget -m YOUR_URL_HERE". If you want to do it in Perl I guess you can use WWW::Mechanize to find and follow the image links and download them locally. You will still need a browser to render the page in the end.
Re: Download Webpage as how browser is showing a webpage
by GrandFather (Saint) on Oct 14, 2011 at 07:58 UTC

    What code are you using currently?

    True laziness is hard work