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

Hi , Can I design a Perl Script to which I can pass a URL and that perl script will then load the URL in the browser . Please let me know on the above problem . Thankyou !
  • Comment on Load URL in Web Browser Using Perl Script

Replies are listed 'Best First'.
Re: Load URL in Web Browser Using Perl Script
by blue_cowdawg (Monsignor) on Jul 31, 2003 at 16:12 UTC

    Two words: Problem Definition!

    What platform? WinBloze? Linux? Solaris? MacOS?

    The solution to what you are trying to do depends on where you are trying to do it.

    On Unix/Linux I would do something like:

        . . . previous code (lots of handwaving) . . . # $netscape contains the full path to the # netscrape browser # # $url contains the URL I want opened. system(sprintf("%s %s",$netscape,$url)); . . . .


    Peter @ Berghold . Net

    Sieze the cow! Bite the day!

    Test the code? We don't need to test no stinkin' code! All code posted here is as is where is unless otherwise stated.

    Brewer of Belgian style Ales

      is the vice-versa possible ??? i.e from the web browser can i fetch the url and pass it to a perl script . Thanks for ur previous help .

        What are you trying to accomplish? Web scrapes?

        If you are trying to scrape results from a web query look at LWP::UserAgent.


        Peter @ Berghold . Net

        Sieze the cow! Bite the day!

        Test the code? We don't need to test no stinkin' code! All code posted here is as is where is unless otherwise stated.

        Brewer of Belgian style Ales

Re: Load URL in Web Browser Using Perl Script
by tcf22 (Priest) on Jul 31, 2003 at 16:22 UTC
    On Win32 you can use Win32::OLE to create an Internet Explorer window.
    use strict; use Win32::OLE; my $iexplorer = Win32::OLE->new('InternetExplorer.Application'); $iexplorer->Navigate('about:blank'); sleep 1 while($iexplorer->busy); $iexplorer->{Visible} = 1; $iexplorer->Navigate('http://www.google.com');
Re: Load URL in Web Browser Using Perl Script
by Corion (Patriarch) on Jul 31, 2003 at 16:33 UTC

    If you want to retrieve HTML and then display it in a browser window, the modules LWP::Simple respective WWW::Mechanize together with HTML::Display might be of interest to you.

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
Re: Load URL in Web Browser Using Perl Script
by Mr. Muskrat (Canon) on Jul 31, 2003 at 16:16 UTC
    I beleive that you may be trying to write is a proxy. If this is the case, then a Super Search for "proxy" will yeild some nodes on the subject. Also perhaps a google search for perl proxy would help.
Re: Load URL in Web Browser Using Perl Script
by bobn (Chaplain) on Jul 31, 2003 at 17:37 UTC

    Didn't you ask a lot of similar questions a couple of weeks ago, usually stating that it hand to be "done in Unix"?

    If not, please accept my apologies and disregard the following.

    If you are that person, just what part of the previous replies (on the order of 'read the doc, do some work yourself, stop asking the same questions over and over again' did you *not* understand?

    --Bob Niederman, http://bob-n.com