Deseo realizar un registro automático a una página de la empresa. Esta sirve para poder registrar la hora de entrada, pero, sin embargo, olvido ingresar por lo que a veces paso una hora hasta que me acuerdo
La página está construida en xhtml por lo que me di a la tarea de buscar en san Google y pude llegar al módulo WWW::Mechanize. Sin embargo, por alguna razón (aunque creo que es porque el campo password del <form> no posee ID) no logro registrarme o bien no logro hacer que lo haga.
Quisiera saber si hay alguna forma más fácil de realizar esto, porque sé que para Perl es posible (o al menos eso deseo con mi corazón, ja,ja,ja,ja )
Aquí está el código que tengo actualmente.
Using perl Syntax Highlighting
- use strict;
- use warnings;
- use strict;
- use WWW::Mechanize;
- use HTTP::Cookies;
- my $outfile = "out2.htm";
- my $url = "http://IP_DEL_SERVER:8080/coreIcon/faces/Login/login.xhtml";
- my $username = '90070';
- my $pform = 'login_form:j_id16';
- my $password = 'mi_password';
- my $mech = WWW::Mechanize->new();
- $mech->cookie_jar(HTTP::Cookies->new());
- $mech->get($url);
- $mech->form_id('login_form');
- $mech->field("login_form:userInput", $username);
- $mech->field($pform, $password);
- $mech->click;
- my $output_page = $mech->content();
- print $output_page;
- open(OUTFILE, ">$outfile");
- binmode(OUTFILE, ":utf8");
- print OUTFILE "$output_page";
- close(OUTFILE);
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4
Este es el código fuente de la página xhtml:
Using html4strict Syntax Highlighting
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <link class="component" href="/coreIcon/faces/a4j/s/3_3_3.Finalorg/richfaces/renderkit/html/css/basic_both.xcss/DATB/eAHbdnRLUujyGdIAFdEEQQ__" rel="stylesheet" type="text/css" />
- <link class="component" href="/coreIcon/faces/a4j/s/3_3_3.Finalorg/richfaces/renderkit/html/css/extended_both.xcss/DATB/eAHbdnRLUujyGdIAFdEEQQ__" media="rich-extended-skinning" rel="stylesheet" type="text/css" />
- <link class="component" href="/coreIcon/faces/a4j/s/3_3_3.Finalcss/panel.xcss/DATB/eAHbdnRLUujyGdIAFdEEQQ__" rel="stylesheet" type="text/css" />
- <script src="/coreIcon/faces/a4j/g/3_3_3.Finalorg.ajax4jsf.javascript.AjaxScript" type="text/javascript">
- </script>
- <script src="/coreIcon/faces/a4j/g/3_3_3.Finalorg/ajax4jsf/javascript/scripts/form.js" type="text/javascript">
- </script>
- <script src="/coreIcon/faces/a4j/g/3_3_3.Finalorg.ajax4jsf.javascript.PrototypeScript" type="text/javascript">
- </script>
- <script src="/coreIcon/faces/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/utils.js" type="text/javascript">
- </script>
- <script src="/coreIcon/faces/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/browser_info.js" type="text/javascript">
- </script>
- <script src="/coreIcon/faces/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/modalPanel.js" type="text/javascript">
- </script>
- <script src="/coreIcon/faces/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/modalPanelBorders.js" type="text/javascript">
- </script>
- <link class="component" href="/coreIcon/faces/a4j/s/3_3_3.Finalorg/richfaces/renderkit/html/css/modalPanel.xcss/DATB/eAHbdnRLUujyGdIAFdEEQQ__" rel="stylesheet" type="text/css" />
- <script src="/coreIcon/faces/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/jquery/jquery.js" type="text/javascript">
- </script>
- <script src="/coreIcon/faces/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/tooltip.js" type="text/javascript">
- </script>
- <link class="component" href="/coreIcon/faces/a4j/s/3_3_3.Finalorg/richfaces/renderkit/html/css/tooltip.xcss/DATB/eAHbdnRLUujyGdIAFdEEQQ__" rel="stylesheet" type="text/css" />
- <link class="component" href="/coreIcon/faces/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/css/msg.css" rel="stylesheet" type="text/css" />
- <link class="component" href="/coreIcon/faces/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/css/msgs.css" rel="stylesheet" type="text/css" />
- <link class="component" href="/coreIcon/faces/a4j/s/3_3_3.FinalMETA-INF/skins/darkX.xcss/DATB/eAHbdnRLUujyGdIAFdEEQQ__" rel="stylesheet" type="text/css" />
- <link class="component" href="/coreIcon/faces/a4j/s/3_3_3.FinalMETA-INF/skins/darkXExt.xcss/DATB/eAHbdnRLUujyGdIAFdEEQQ__" media="rich-extended-skinning" rel="stylesheet" type="text/css" />
- <script type="text/javascript">window.RICH_FACES_EXTENDED_SKINNING_ON=true;</script>
- <script src="/coreIcon/faces/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/skinning.js" type="text/javascript">
- </script>
- </head>
- <body>
- <div class="rich-panel " id="j_id2" style=" width:400px; vertical-align:middle; margin-left:auto; margin-right:auto ">
- <div class="rich-panel-header " id="j_id2_header">
- Ericsson Login</div>
- <div class="rich-panel-body " id="j_id2_body">
- <form id="login_form" name="login_form" method="post" onkeypress="if (event.keyCode == 13) { document.getElementById('login_form:loginb').click(); return false; }" action="/coreIcon/faces/Login/login.xhtml">
- <div id="login_form:mp2" style="display: none;">
- <input autocomplete="off" id="login_form:mp2OpenedState" name="login_form:mp2OpenedState" type="hidden" />
- <div class="rich-modalpanel " id="login_form:mp2Container" style="position: absolute; display: none; z-index: 100; background-color: inherit;">
- <div class="rich-mpnl-mask-div-opaque rich-mpnl-mask-div" id="login_form:mp2Div" style="z-index: -1;">
- <button class="rich-mpnl-button" id="login_form:mp2FirstHref">
- </button>
- </div>
- <div class="rich-mpnl-panel">
- <div class="rich-mp-container" id="login_form:mp2CDiv" style="position: absolute; left: 0px; top: 0px; z-index: 9;">
- <div class="rich-mpnl-shadow" id="login_form:mp2ShadowDiv">
- </div>
- <div class=" rich-mpnl-content" id="login_form:mp2ContentDiv">
- <table border="0" cellpadding="0" cellspacing="0" class="rich-mp-content-table" id="login_form:mp2ContentTable" style="width: 1px;height: 1px;">
- <tr style="height: 99%">
- <td class="rich-mpnl-body" valign="top">
- <div align="center">
- <img src="/coreIcon/img/wait.gif" />
- </div>
- </td>
- </tr>
- </table>
- </div>
- </div>
- </div>
- <div class="rich-mpnl-mask-div rich-mpnl-mask-div-transparent" id="login_form:mp2CursorDiv" style="z-index: -200;">
- <button class="rich-mpnl-button" id="login_form:mp2LastHref">
- </button>
- </div>
- <script type="text/javascript">new ModalPanel('login_form:mp2',
- {
- width: -1,
- height: -1,
- minWidth: -1,
- minHeight: -1,
- resizeable: false,
- moveable: true,
- left: "auto",
- top: "auto",
- zindex: 100,onresize: '',onmove: '',onshow: '',onhide: '',onbeforeshow: '',onbeforehide: '',
- domElementAttachment: "",
- keepVisualState: false,
- showWhenRendered: false,
- selectBehavior: "disable",
- autosized: true,
- overlapEmbedObjects: false});</script>
- </div>
- <script type="text/javascript">
- </script>
- </div>
- <span id="login_form:esperar:status">
- <span id="login_form:esperar:status.start" style="display: none">
- </span>
- <script type="text/javascript">
- window.document.getElementById('login_form:esperar:status.start').onstart=function(){Richfaces.showModalPanel('mp2');;};
- </script>
- <span id="login_form:esperar:status.stop">
- </span>
- <script type="text/javascript">
- window.document.getElementById('login_form:esperar:status.stop').onstop=function(){Richfaces.hideModalPanel('mp2');;};
- </script>
- </span>
- <table>
- <tbody>
- <tr>
- <td>
- <table>
- <tbody>
- <tr>
- <td>
- Usuario:</td>
- <td>
- <input id="login_form:userInput" type="text" name="login_form:userInput" tabindex="0" />
- </td>
- </tr>
- <tr>
- <td>
- Password:</td>
- <td>
- <input type="password" name="login_form:j_id16" value="" />
- <br />
- </td>
- </tr>
- <tr>
- <td>
- <span class="rich-tool-tip " id="login_form:j_id21" style="z-index:99; ">
- <span id="login_form:j_id21content">Logearse</span>
- <span id="login_form:j_id21script" style="display:none">
- <script type="text/javascript" id ="scriptlogin_form:j_id21">
- new ToolTip("login_form:j_id21","login_form:loginb",{'showEvent':'mouseover'} );
- </script>
- </span>
- </span>
- <input id="login_form:loginb" name="login_form:loginb" onclick="A4J.AJAX.Submit('login_form',event,{'similarityGroupingId':'login_form:j_id20','parameters':{'login_form:j_id20':'login_form:j_id20'} ,'containerId':'login_form:esperar'} );A4J.AJAX.Submit('login_form',event,{'similarityGroupingId':'login_form:loginb','parameters':{'login_form:loginb':'login_form:loginb'} ,'containerId':'login_form:esperar'} );return false;" value="Login" type="button" />
- </td>
- </tr>
- </tbody>
- </table>
- </td>
- <td>
- <!-- <h:graphicImage style="margin-left:auto; margin-right:auto"
- value="/img/logo.jpg" />
- -->
- <img src="/coreIcon/img/ericsson_logo_trasparente1.png" style="margin-left:auto; margin-right:auto; padding-bottom: 30px;" />
- </td>
- </tr>
- </tbody>
- </table>
- <input type="hidden" autocomplete="off" name="login_form" value="login_form" />
- <input type="hidden" autocomplete="off" name="autoScroll" value="" />
- <input type="hidden" autocomplete="off" name="login_form:_link_hidden_" value="" />
- <input type="hidden" autocomplete="off" name="login_form:j_idcl" value="" />
- <script type="text/javascript">function clear_login_form() {
- _clearJSFFormParameters('login_form','',['login_form:_link_hidden_','login_form:j_idcl']);
- }
- function clearFormHiddenParams_login_form(){clear_login_form();}
- function clearFormHiddenParams_login_form(){clear_login_form();}
- clear_login_form();</script>
- <input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id4" autocomplete="off" />
- </form>
- <script type="text/javascript">
- window.onload = function() {
- document.getElementById('login_form:userInput').focus();
- }
- </script>
- <dl id="msgsError" class="rich-messages" style="display: none; color:red">
- <dt>
- </dt>
- </dl>
- </div>
- </div>
- </body>
- </html>
Coloreado en 0.008 segundos, usando GeSHi 1.0.8.4
De antemano, muchas gracias.