Re: Problem logging on to site with MECHANIZE

2004-01-28 Thread bzzt
could it be that I am behing a firewall??

Bzzt [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I'm trying to log on to this site (www.thecityvibe.com/forum/) with the
 followin script but doesn't seem to succeed. Anyone knows what the problem
 might be?



 #!/usr/local/ActivePerl-5.6/bin/perl -w
 use warnings;
 use strict;
 use WWW::Mechanize;
 my $agent = WWW::Mechanize-new();

 $agent-get('http://www.thecityvibe.com/forum/');
 die Can't even get the home page: , $agent-response-status_line
  unless $agent-success;

 $agent-field(username = vagelis);
 $agent-field(password = vagelis);
 $agent-submit();

 #print $agent-content(),\n;
 #print $agent-uri();






RE: Problem logging on to site with MECHANIZE

2004-01-28 Thread \(William\) Wenjie Wang
-Original Message-
From: bzzt [mailto:[EMAIL PROTECTED]

[snip]

 I'm trying to log on to this site (www.thecityvibe.com/forum/) with the
 followin script but doesn't seem to succeed. Anyone knows what
the problem
 might be?


I've modified your codes a bit, and it appears submitted the first login
form correctly.  Replacing vagelis with correct login details to it should
prove everything, right or wrong:-)

 #!/usr/local/ActivePerl-5.6/bin/perl -w
 use warnings;
 use strict;
 use WWW::Mechanize;
 my $agent = WWW::Mechanize-new();

 my $MyResponse = $agent-get('http://www.thecityvibe.com/forum/');
 die Can't even get the home page: , $agent-response-status_line
  unless ($MyResponse-is_success);
 my $form = $agent-current_form();

 $form-dump;   # debug info, just to make sure you've got the expected form

 $agent-field(username = vagelis);
 $agent-field(password = vagelis);
 $form-dump;   # debug info, just to make sure you've assigned the correct
values

 $agent-submit();

Regards,
WWang
--
Wenjie Wang(a.k.a. William)[EMAIL PROTECTED]
WANG Infonology Systems  Ph:(02)-98712018; mob:0412688380
http://users.bigpond.net.au/WISeAgent
==



RE: Problem logging on to site with MECHANIZE

2004-01-28 Thread \(William\) Wenjie Wang

-Original Message-
From: bzzt [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 28 January 2004 9:16 PM
To: [EMAIL PROTECTED]
Subject: Re: Problem logging on to site with MECHANIZE


could it be that I am behing a firewall??


I'm behind a firewall and I've got no problem to fetch a form from
http://www.thecityvibe.com/forum/; using the modified script I've sent out
earlier.

you might have to set following environment variables, if you're behind a
firewall:
HTTPS_PROXY=http://yourproxyserver:port
HTTP_PROXY=http://yourproxyserver:port

Regards,
WWang
--
Wenjie Wang(a.k.a. William)[EMAIL PROTECTED]
WANG Infonology Systems  Ph:(02)-98712018; mob:0412688380
http://users.bigpond.net.au/WISeAgent
==



Re: Problem logging on to site with MECHANIZE

2004-01-23 Thread Gedanken
On Fri, 23 Jan 2004, bzzt wrote:

 I'm trying to log on to this site (www.thecityvibe.com/forum/) with the
 followin script but doesn't seem to succeed. Anyone knows what the problem
 might be?

I dont have time to test this from command line, but heres one possible 
head scratching solution.  I dont know why this works, but i have MANY 
sites on which i have to do this.  Regular form submits silently fail, 
usually reloading the same page i was just on.  when i do this trivial 
(but explicit) change, they work.

basically i manually set the form action... to the same thing it was 
already set to.  and voila, stuff starts working.   Ill edit your version 
below to show you what i mean.
 
if that doesnt work, try using a click() instead of a submit().

matt
 
 #!/usr/local/ActivePerl-5.6/bin/perl -w
 use warnings;
 use strict;
 use WWW::Mechanize;
 my $agent = WWW::Mechanize-new();
 
 $agent-get('http://www.thecityvibe.com/forum/');
 die Can't even get the home page: , $agent-response-status_line
  unless $agent-success;
 
 # form isnt playing nice for unknown reasons
 # so we manually set action to whatever it already was
 my $form = $agent-current_form();
 my $uri = 
URI-new(http://www.thecityvibe.com/whatevertheformactionwas;);
 $form-action($uri);
 $form-method(POST);
 $agent-field(username = vagelis);
 $agent-field(password = vagelis);
 $agent-submit();
 
 #print $agent-content(),\n;
 #print $agent-uri();
 
 

-- 
gedanken



Re: Problem logging on to site with MECHANIZE

2004-01-23 Thread John J Lee
On Fri, 23 Jan 2004, Gedanken wrote:
[...]
 basically i manually set the form action... to the same thing it was
 already set to.  and voila, stuff starts working.   Ill edit your version
 below to show you what i mean.

Yuck.  Does it also work if you wave a dead chicken at it? ;-)

Why not check the HTTP headers to find out what's going wrong?


John


Re: Problem logging on to site with MECHANIZE

2004-01-23 Thread Gedanken
On Fri, 23 Jan 2004, John J Lee wrote:

 Yuck.  Does it also work if you wave a dead chicken at it? ;-)
 
 Why not check the HTTP headers to find out what's going wrong?

the headers are identical as far as i can tell.  after all, the code 
snippet i sent doesnt actually change anything.  whether its mechanize 
having problems or the javascript on the servers, i have not a clue.  

i agree with your chicken waving comment, i just dont have a better 
explanation.  

Santeria is the cornerstone of Perl. - me
 
 John
 

-- 
gedanken



Re: Problem logging on to site with MECHANIZE

2004-01-23 Thread John J Lee
On Fri, 23 Jan 2004, bzzt wrote:

 I'm trying to log on to this site (www.thecityvibe.com/forum/) with the
 followin script but doesn't seem to succeed. Anyone knows what the problem
 might be?

(without reading your script): no cookie jar?

I don't recall if WWW::Mechanize makes one by default if none is supplied
to the constructor.  If not, that could be your problem.  Look at the HTTP
headers.

What do you get back from the server?


John


Re: Problem logging on to site with MECHANIZE

2004-01-23 Thread John J Lee
On Fri, 23 Jan 2004, Gedanken wrote:

 On Fri, 23 Jan 2004, John J Lee wrote:

  Yuck.  Does it also work if you wave a dead chicken at it? ;-)

  Why not check the HTTP headers to find out what's going wrong?

 the headers are identical as far as i can tell.  after all, the code
[...]

Did you actually check to make sure (eg. with ethereal)?


John


Re: Problem logging on to site with MECHANIZE

2004-01-23 Thread John J Lee
On Fri, 23 Jan 2004, Gedanken wrote:

 On Fri, 23 Jan 2004, John J Lee wrote:

  Yuck.  Does it also work if you wave a dead chicken at it? ;-)

  Why not check the HTTP headers to find out what's going wrong?

 the headers are identical as far as i can tell.  after all, the code
 snippet i sent doesnt actually change anything.  whether its mechanize
 having problems or the javascript on the servers, i have not a clue.

 i agree with your chicken waving comment, i just dont have a better
 explanation.

Forgot to add: the browser must be doing it right, and if the browser
reloads, it's not doing that because it happens to feel like it: There
must (presumably!) be some reason -- even if bogus -- why it does so.


John


RE: Problem logging on to site with MECHANIZE

2004-01-23 Thread Thurn, Martin
This book probably answers all your questions...

http://www.amazon.com/exec/obidos/ASIN/0596001789/thestarwarscol06

 - - Martin



 -Original Message-
 From: John J Lee [mailto:[EMAIL PROTECTED]
 Sent: Friday, January 23, 2004 10:57 AM
 To: [EMAIL PROTECTED]
 Subject: Re: Problem logging on to site with MECHANIZE
 
 
 On Fri, 23 Jan 2004, bzzt wrote:
 
  I'm trying to log on to this site 
 (www.thecityvibe.com/forum/) with the
  followin script but doesn't seem to succeed. Anyone knows 
 what the problem
  might be?