APM: RE: follow HREF='Javascript....

jeremyb at univista.com jeremyb at univista.com
Thu Apr 10 13:32:28 CDT 2003


 well,  I think I'm getting close...   I need to find someway to support js
in the script
since LWP can't do it alone.  Any tips would be greatly appreciated.

-----Original Message-----
From: jeremyb at univista.com
To: austin at mail.pm.org
Sent: 4/10/03 11:39 AM
Subject: APM: follow HREF='Javascript....

  
  I'm putting together an API of sorts for Outlook Web Access on
Exchange
5.5 and 2000.
I only need access to Calendar and Tasks.  I have the Calendar portion
figured out 
but the Tasks folder is a little more difficult to get to   ....it
requires
more clicking from a browser.  The frame source containing the private
folders button has the following
HREF to the private foldere list where the Tasks folder lives:
  <A
HREF='Javascript:parent.SetNewFolderPick("0000000045B57431BE491B4D9D4DD0
878C
6C206E0100405A4B20FCF8D41192CF0050DA1802C20000002D4CC10000").

In order to get that folder ID  (the really long alpha-num string) to
actually return the private folder list you have to select the ID using
that
javascript first with the above HREF.

When I access the folder list ID using the appropriate 
request, after selecting it from the Javascript, IIS just returns the
default (unselected) frame source that does not contain the folder list,
as
if the folder was never selected using the javascript.  Is there a way
to
follow links to javascript like the one above using LWP::UserAgent or
some
such module?

relavent system info:
  RedHAt 7.1
  Perl 5.6.0

The script as it currently is:

#!/usr/bin/perl -w 
use strict;
use LWP::UserAgent;
use HTTP::Cookies;
my ($username, $password) = @ARGV;
my $root_url = 'http://blah.foo.org';
my $url =
"http:\/\/blah\.foo\.org\/exchange\/LogonFrm\.asp\?isnewwindow\=0\&mailb
ox\=
$username";

my $ua = LWP::UserAgent->new;
  $ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt", autosave
=>
1));
 
# use the username above to select a mailbox. ...Then login
my $req = HTTP::Request->new(GET => "$url");
  $req->authorization_basic($username, $password);
  print $ua->request($req)->as_string;
  my $rc = $ua->request($req);
 
# Follow the "main_fr" frame ...this probably isn't needed but I'll get
to
that later.
if ($rc->as_string =~ /SRC="(.*)"\sname="(main_fr)"/i) {
   print "found $2:  $1\n appending to $root_url to GET: \n
$root_url$1\n\n";
   $req = new HTTP::Request("GET", "$root_url$1");
 
   # try to select the private folder list
   $rc = $ua->request($req,
'Javascript:parent.SetNewFolderPick("0000000045B57431BE491B4D9D4DD0878C6
C206
E0100405A4B20FCF8D41192CF0050DA1802C20000002D4CC10000")');
}
 
# access peer_fr frame after selecting the private folder ID above.
# Hope it gives you the list of folders.   ...but it doesn't
if ($rc->as_string =~ /SRC="(.*)"\sname="(peer_fr)"/i) {
   print "found $2:  $1\n appending to $root_url to GET: \n
$root_url$1\n\n";
   $req = new HTTP::Request("GET", "$root_url$1");
   $rc = $ua->request($req);
   print  $rc->content;
}

  




-thanks in advance,
  Jeremy
_______________________________________________
Austin mailing list
Austin at mail.pm.org
http://mail.pm.org/mailman/listinfo/austin



More information about the Austin mailing list