Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: 500 error with LWP:UserAgent

by Khen1950fx (Canon)
on Nov 05, 2014 at 14:14 UTC ( #1106203=note: print w/replies, xml ) Need Help??

in reply to 500 error with LWP:UserAgent

Stick with POST. GET just gives you an "incorrect" warning; however, using POST will give you an exception. Here's the code that I ran:
#!/usr/bin/perl -l use strict; use warnings; use Encode; use Encode::Locale; require LWP::UserAgent; require HTTP::Request; my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 } ); $ua->agent("Mozilla/8.0"); $ua->timeout(10); $ua->protocols_allowed( ['https'] ); my $req = HTTP::Request->new( 'POST', '' ); $req->header( 'Accept' => 'text/html' ); my $res = $ua->request($req); if ( $res->is_success ) { print $res->decoded_content; } else { print "Error: " . $res->status_line . "\n"; }
And the result:
<!-- RSisException --><html> <head> <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1 +"> <meta content="-1" http-equiv="Expires"> <meta content="Monday, 01-Jan-90 00:00:00 GMT" http-equiv="Expires"> <meta content="no-cache" http-equiv="Pragma"> <meta content="no-cache" http-equiv="Cache-Control"> <script type="text/javascript" src="/dtagent56_n3_5964.js" data-dtconf +ig="rid=RID_1948368250|rpid=272727326|tp=500,50,0|">< +/script><link type="text/css" href="/sis/estilos/unica/9999.css" rel= +"StyleSheet"> <link type="text/css" rel="StyleSheet" href="/sis/estilos/.css"> <script src="/sis/javascript/xsl/RSisException.js" type="text/javascri +pt"></script><script src="/sis/javascript/utilSis.js" type="text/java +script"></script> </head> <body onload="load()"> <div id="divCuerpo" style="overflow:auto;height:90%;"> <table class="contenedor"> <tr> <td height="52" colspan="2" align="right" class="tituloSuperior"><img +height="52" onerror="this.src='/sis/graficos/logotipos/comunes/redsys +.gif';" src="/sis/graficos/logotipos/comunes/-1.gif" alt="Terminal de + pagos virtuales"></td> </tr> <tr> <td colspan="2" class="separador">&nbsp;</td> </tr> <tr> <td colspan="2" class="resultado"><font class="denegacion"> <!--:--></font></td> </tr> <tr> <td colspan="2" class="separador">&nbsp;</td> </tr> <tr> <td colspan="2" class="botones"> <form action="" method="get"> <div style="position:relative;visibility:hidden" id="divImg"> <input type="button" class="botonAccion" onmouseover="hov(this,'botonA +ccion btnhov')" onmouseout="hov(this,'botonAccion')" value="Imprimir" + onClick="javascript:imprimir();" alt="Imprimir"><input type="button" + class="botonAccion" onmouseover="hov(this,'botonAccion btnhov')" onm +ouseout="hov(this,'botonAccion')" value="Cerrar" onClick="window.clos +e();" alt="Cerrar"> </div> <div style="position:relative;visibility:visible" id="divImgNoScript"> <NOSCRIPT value="Imprimir"> &nbsp; <input type="submit" class +="buttonAccion" value="Cerrar" ALT="Pulse el bot&oacute;n para cerrar +"> </NOSCRIPT> </div> </form> </td> </tr> </table> </div> <div id="divPie" style="overflow:visible; height:55px;"> <table cellpadding="0" cellspacing="0" border="0" width="100%"> <tr style="background-color:#8e9092;"> <td height="52" style="width:100%">&nbsp;</td> </tr> </table> </div> </body> </html>

Make sure that you have these modules installed:


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (None)
    As of 2021-10-19 03:10 GMT
    Find Nodes?
      Voting Booth?
      My first memorable Perl project was:

      Results (76 votes). Check out past polls.