Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^7: WWW::Mechanize click_button() not working in AIX

by perl_monster (Novice)
on Jul 11, 2012 at 00:09 UTC ( [id://980982]=note: print w/replies, xml ) Need Help??


in reply to Re^6: WWW::Mechanize click_button() not working in AIX
in thread WWW::Mechanize click_button() not working in AIX

Ok, so the add_handler call showed a bunch of log messages. Below is the excerpt of the log

GET https://www.myreports.com/tax_report.php?dc_range=Y&dc_date1=7%2F9 +%2F2012&dc_date2=7%2F9%2F2012 Accept-Encoding: gzip Referer: https://www.myreports.com/admin/ User-Agent: WWW-Mechanize/1.72 Cookie: PHPSESSID=df9f4mmljub54dfi0vvdm2lh12 Cookie2: $Version="1" (no content) HTTP/1.1 200 OK Cache-Control: post-check=0, pre-check=0 Connection: close Date: Wed, 11 Jul 2012 00:00:30 GMT Pragma: no-cache Server: Apache Vary: Accept-Encoding,User-Agent Content-Encoding: gzip Content-Length: 555 Content-Type: text/html; charset=iso-8859-1 Expires: Thu, 19 Nov 1981 08:52:00 GMT Client-Date: Wed, 11 Jul 2012 00:00:31 GMT Client-Peer: xx.xx.xx.xx:xxx Client-Response-Num: 1 Client-SSL-Cert-Issuer: /C=GB/ST=Greater Manchester/L=Salford/O=COMODO + CA Limited/CN=COMODO High-Assurance Secure Server CA Client-SSL-Cert-Subject: /C=US/postalCode=75238/ST=Texas/L=Dallas/stre +et=10300 Sanden Dr Suite 100/O=SpeedFC/OU=PlatinumSSL Wildcard/CN=*.m +yreports.com Client-SSL-Cipher: DHE-RSA-AES256-SHA Client-SSL-Warning: Peer certificate not verified

The only warning I can see is the last line, looks like the SSL certificate cannot be verified. Not sure if this is causing the issue. In my Win machine, the program works even after the Warning.

Replies are listed 'Best First'.
Re^8: WWW::Mechanize click_button() not working in AIX
by onelesd (Pilgrim) on Jul 11, 2012 at 03:26 UTC

    The warning is due to LWP::UserAgent not verifying the certificate. You can make it verify if you want (look at ssl_opts()), but that doesn't seem to be your problem.

    This debug excerpt doesn't look like the part we are interested in. Move the add_handler() calls to just before you call click_button(). You just want to verify whether or not the form is being submitted, in which case you'll see the request and then hopefully a response. If you don't see a request then you know for sure click_button() isn't working, but I can't tell you why it wouldn't be.

    If you can't get click_button() to go you could work around it- build the request like you would if you were just using LWP::UserAgent. Not ideal but sometimes you gotta just get things working.

      Yes, thats what I did, the add_handler() is called just before the click_button() call (code below), and I do not see any request or response. There are a bunch of random text that appears though, but it doesn't look like a request and/or response (elaborate log given below)

      .... #Logging $mech->add_handler("request_send", sub { shift->dump; return }); $mech->add_handler("response_done", sub { shift->dump; return }); $mech->click_button(input => $inputobject); print $mech->status() . "\n"; if ( ! $mech->success() ) { print "Cannot Login....\n"; print( STDERR $mech->status() . "\n" ); } ..... Log- GET https://www.myreports.com/admin/tax_report.php?dc_range=Y&dc_date1 +=7%2F9%2F2012&dc_date2=7%2F9%2F2012 Accept-Encoding: gzip Referer: https://www.myreports.com/admin/tax_report.php?dc_range=Y&dc_ +date1=7%2F9%2F2012&dc_date2=7%2F9%2F2012 User-Agent: WWW-Mechanize/1.72 Cookie: PHPSESSID=m712pk33kr9ip5ti2be6b8dre3 Cookie2: $Version="1" (no content) HTTP/1.1 200 OK Cache-Control: post-check=0, pre-check=0 Connection: close Date: Wed, 11 Jul 2012 04:18:42 GMT Pragma: no-cache Server: Apache Vary: Accept-Encoding,User-Agent Content-Encoding: gzip Content-Length: 555 Content-Type: text/html; charset=iso-8859-1 Expires: Thu, 19 Nov 1981 08:52:00 GMT Client-Date: Wed, 11 Jul 2012 04:18:43 GMT Client-Peer: xx.xx.xxx.xxx:443 Client-Response-Num: 1 Client-SSL-Cert-Issuer: /C=GB/ST=Greater Manchester/L=Salford/O=COMODO + CA Limited/CN=COMODO High-Assurance Secure Server CA Client-SSL-Cert-Subject: /C=US/postalCode=75238/ST=Texas/L=Dallas/stre +et=10300 Sanden Dr Suite 100/O=SpeedFC/OU=PlatinumSSL Wildcard/CN=*.m +yreports.com Client-SSL-Cipher: DHE-RSA-AES256-SHA Client-SSL-Warning: Peer certificate not verified \37\x8B\10\0\0\0\0\0\0\3\xADTMo\x1A1\20\xBD\xF3+\xA6>\xF4\6\16\x89z\x8 +0\xEE\xAE\x94.\x89\22\x89\xB6\xA8!j{4k\xC3Z\xF5\xDA\xAB\xF5\20\xA0\xB +F\xBE\xFEX\xBE\2\x89\xA2\xA8\34X\x8F\xFD\xE6\xCD\33\x8Fg\x92\17\xA3\x +EF\xF9\xF4\xF7\xE4\6J\xAC\24t\xC0\xFF&\x8F_\xC6\xF79\x90.\xA5?\xAFrJG +\xD3\21\xFC\xBA\x9B~\35C\xBFw\1\17\xD8\xC8\2)\xBD\xF9F\2\x9C\x94\x88\ +xF5\x90\xD2\xD5j\xD5[]\xF5L\xB3\xA0\xD3\37t\xED\xF9\xFA\xDE\xB5]vm\xF +0\xEBq\xE4$\xEB$!\xDC\xBAR\xDA\xA6g\10\xFA\x83\xC1 \xFA\21\17\32*\xA6 +\27)\21\x9A\xC0n\xE59\4\xE3Y\xD0\x90\xA0D%\xB2\x87Z\10~\x9B\xC3\xA5\x +93\xD9\x85k^I=\34\x9B\x85\xD4\t\x8D\x80\10VR\xFF\x81\xB2\21\xF3\x94\x +D0\xC2Z\xAA<\xA4\xE7V\4\32\xA1Rbq\xA3\x84-\x85@\2\xB8\xA9EJP\xAC\xD1C +\tuai\x8C\xDBIf\x86oZ\xCA\xB2\x9F]\27\x85Yj\x84\x8Fzf\xEB\xCF\xDDn\xF +C\x82\x8B\17\xF7N\x80C\4h\xC4s\xF9\4\x92\xA7\xA40\32\x85F\22\xCF\xC2\ +xD1\xDC4\25T\2K\xE3\xCEkc\x8F\16\x91\xCD\x94\10\x9EA4\x81B(U3\xCE\xA5 +\xBF\x96\x8Bh\xDB\x9A\25\xAD\xBDw\x8D\xEE\xCD\xF1F\xDC,\xA10\xDEI\xA7 +\xE4\xD21(f]Q\32\xB9(]\xE8\xAD|,\x9FQ\xD1\xE7\\/\x90\xF3-\xA1b3\xA1H\ +xF6hE\xA3Y%\x86\x8E\x81\xBF\xEA\xD0*8\x81\4\x98\xD4\xF5\22\17\xAAC\xC +0\x93\xEE\xAE\xE5\x89\xA9\xA5\xB3\10X\xF9\xD7}\xFB\x9F\\\xE5\xCE\xF1\ +x9C\xC6?Q\xF5\xEEL'\xCEX\x99\x86\xC7L\xDF\26\xFD\35\xD9\xD7m\x98\xED\ +r\4\x9B\37e\xFE?\xB3<\xFBX\xDC\xFF\x9B\xB4\xDA\xE5\xAC\x92\xB8+O\xE8M +\xD0f\xF5\x82\xC6W\xDF\x9C\xB3|3\34l\34F*%\xE7~^\xC4;a\5J\xB3\x7F\26\ +xF1\x91\xD0C.\xDFuY(\xC8~\x93m\x87\4\x89\x93\5n\x97j.\x95\xAA\x84os\x +C8\x99R\x90\xBB\xB5h\xE0\xCET"\xA1\xAC\x9D\6\xD4\xB5\xB7\37\24q@\xB8\ +xDEw\x83,\xEB\xFC\3\x98\27\7\tl\5\0\0

      As you said, it looks like the click_button() or any other such method isn't working. One more interesting point is , I just tried the program on my Mac and its not working on it either. I am getting inclined to believe that the WWW::Mechanize module doesn't quite like the Unix/Linux architecture. Also, in my Mac, I am unable to log on to the site from the web browser and it says un-trusted SSL cert security error, but that might be because I do not have the Proxy setting done on the browsers properly. Not entirely sure what is going on here

      I think I was looking at the wrong place in the Log. One more thing i found this morning is that the "POST" is returning with a "HTTP/1.1 302 Found" in the AIX machine, where as the same code and same URL returns "HTTP/1.1 200 OK" in the Windows machine. Not sure where its trying to re-direct to. If I use  $mech->requests_redirectable([]); to avoid being redirected, it returns with a 302 and also says "Cannot Login...". Is there I way I can fetch the URL where it re-directs to, using Mech? I was hoping that Mech should take care of that itself, but looks like it isn't. My Windows machine is set to detect proxy server settings automatically and I dont see any re-direct when I try to open the login page in the browser.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://980982]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-24 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found