How to use Mozilla within Perl (to replace IE)

D

DG

Hello and thanks for the help,

I've used IE within Perl to access web sites. Given the recent IE security
problems, I'd like to replace it with Mozilla 1.71.
Unfortunately, I don't know how.

Below is an example of how I have used IE within Perl. How would I change
this code to access Mozilla?

thanks for the help,
DG


use Win32::OLE;

$BROWSER = Win32::OLE->new('InternetExplorer.Application'); #open the
browser
$BROWSER->with(Visible => 1, Top => 1, Left => 1, Height => 50, Width =>
500); #shrink the browser window, and place it in the upper left corner
$BROWSER->Navigate("http://wwws.yahoo.com"); #get the
cookies

do #wait until the first page finishes loading (to get the cookies) before
logging in
{
select(undef,undef,undef,0.1); #sleep 0.1 seconds (finer time resolution
than "sleep" command)
$stat=$BROWSER->{Busy}; #get the status of the browser load
}
while ($stat); #continue looping if the browser is NOT yet
done loading

# get the HTML data
$body=$BROWSER->Document->{body}; #get the hash string
returned by the browser
$mystring= $body->{innerHTML}; #get the HTML data from
browser
#$mystring= $body->{innerTEXT}; #removes all HTML commands
leaving only the text
 
D

David K. Wall

I've used IE within Perl to access web sites. Given the recent IE
security problems, I'd like to replace it with Mozilla 1.71.

Just use LWP::UserAgent and HTTP::Request. See lwpcook for examples and
lwptut for a tutorial on using the LWP libraries.

LWP (short for ``Library for WWW in Perl'') is a very popular
group of Perl modules for accessing data on the Web.
 
D

DG

David K. Wall said:
Just use LWP::UserAgent and HTTP::Request. See lwpcook for examples and
lwptut for a tutorial on using the LWP libraries.

LWP (short for ``Library for WWW in Perl'') is a very popular
group of Perl modules for accessing data on the Web.

Thanks for the reply.

I've used these libraries in the past (prior to switching to IE), and found
they didn't meet my needs. For example: sometimes I need a browser window
to open for the user to view, and these libraries don't do that. Also, I've
had problems with secure sites (https://) not liking the way these libraries
handle cookies (usually because these sites use JavaScript to modify
cookies). I worked around these problems for a while, but finally decided
that it was just easier to just use a full blown browser. That's when I
switched to using IE within Perl (I also found a side benefit that I didn't
need to upgrade the code when new developments in web pages occurred,
because handlers for these upgrades were built into the browser updates).
So, based on this past experience, I'd like to use a full browser within
Perl. That's why I'm asking how to use Mozilla within Perl.

But thanks for taking the time to suggest a solution,
DG
 
J

Joe Smith

Shailesh said:
In general, to retrieve/post HTTP, use the LWP libraries.

Yes, but if you know ahead of time that the HTML will be containing
JavaScript, then you'll want to use a browser instead of just LWP.
-Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top