hello Kashyap,
I tried your solution, but i think i am getting stuck at proxy.
secondly after entering credentials my website produces a new page where i have to click an 'ok' button and then it takes me back to where i was.
here is the problem description in short:
1. post your url in browser:
https://myrel/files/file.doc
2. you get a logon page (URL still looking same)
3. enter field names: username/password
4. press 'ok' button (name = bsubmit)
after successfull login:
5. you get new page:
https://myurl/pagSuccess/
6. you have to click 'ok' ( field name = successbtn ) on this page now to go back to where you wanted to go...
7. then you get a firefox dialog:
where you have to select (radio button) 'Save File'
press ok
8. you are done!!! (saves the file to default location)
here is the code which is failing on proxy:
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
#print "Content-type: text/html\n\n";
my $username = "myid";
my $password = "mypass";
my $outfile = "testout.doc";
$ENV{HTTPS_PROXY} = 'http://myproxy:8080';
my $mech = WWW::Mechanize->new( );
my $url = 'https://myurl/files/file.doc';
$mech->get($url);
$mech->form_name('frmLogin');
$mech->field(username => "$username");
$mech->field(password => "$password");
$mech->click('bsubmit');
$mech->click('successbtn'); # here i am hoping this will click the 'ok' button the next page
my $response = $mech->content();
open(OUTFILE, ">$outfile");
print OUTFILE "$response";
close(OUTFILE);
error i am getting:
Error GETing
https://myurl/files/file.doc: proxy connect failed: PROXY ERROR HEADER, could be non-SSL URL:
HTTP/1.0 504 Gateway Time-out
Server: squid/
Date:
Content-Type: text/html
Content-Length: 1117
X-Squid-Error: ERR_CONNECT_FAIL 238