0
How do I fill a field of a page in Curl and this does not send the data via form, but via Javascript?
The page in question is this:
<script type='text/javascript' src='js/juridico.js'></script>
<script type='text/javascript' src='dwr/engine.js'></script>
<script type='text/javascript' src='dwr/util.js'></script>
<script type='text/javascript' src='dwr/interface/ValidacaoCaptchaAction.js'></script>
<!-- Início do include do captcha para qualquer página -->
<script type="text/javascript" language="Javascript1.1">
var popup = true;
if (window.dialogArguments) { // IE
window.opener = window.dialogArguments;
}
window.onload = load;
window.onbeforeunload = unload;
function validaNumeroCaptcha(e){
var unicode=e.charCode? e.charCode : e.keyCode;
if (unicode!=8){ //if the key isn't the backspace key (which we should allow)(127=DEL Key)
if (unicode<48||unicode>57) //if not a number
return false; //disable key press
}
document.getElementById("mensagem").innerHTML = " ";
return true;
}
function setTextoCaptchaFocus(){
document.getElementById('captcha_text').focus();
}
function recarregaImagem(){
document.getElementById('captcha_image').src = "imagens/icon_wait.gif";
var ran_number = Math.random()*5;
var captcha_servlet = "captcha.svl?" + ran_number;
document.getElementById('captcha_image').src = captcha_servlet;
document.getElementById('captcha_text').value = "";
document.getElementById('captcha_text').focus();
}
function gerar()
{
recarregaImagem();
}
function load(){
if (window.opener)
{
window.opener.document.body.style.opacity = 0.4;
window.opener.document.body.style.filter = "filter: alpha(opacity=40)";
}
setTimeout("gerar()", 1000);
}
function unload()
{
if (window.opener)
{
window.opener.document.body.style.opacity = 1;
window.opener.document.body.style.filter = "filter: alpha(opacity=100)";
}
var vReturnValue = new Object();
vReturnValue.captcha_text = document.getElementById("captcha_text").value;
window.returnValue = vReturnValue;
}
function verificaNumero(campo)
{
if (campo.value.length == 5)
{
ValidacaoCaptchaAction.isCaptchaValid(campo.value, ret);
}
}
function ret(valido)
{
if (valido)
{
window.document.getElementById("captcha_text").style.display = "none";
window.document.getElementById("wait").innerHTML = "Aguarde...";
window.document.getElementById("wait").style.display = "inline";
if (window.document.getElementById("linkCaptcha"))
{
document.location.reload(true);
}
if (window.opener && popup)
{
window.close();
}
}
else
{
document.getElementById("mensagem").innerHTML = "O número digitado não corresponde à imagem exibida. Favor informar o código novamente.";
gerar();
return false;
}
}
</script>
<head>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="/css/layout.css" rel="stylesheet" type="text/css" />
<link href="/css/tjmg2007.css" rel="stylesheet" type="text/css" />
<title>Captcha</title>
</head>
<body style="background-color: white;">
<div id="mensagem" style="color: #FF0000; font-weight: bolder; text-align: center;"> </div>
<table border="0" width="100%">
<tr>
<td class="medio" align="center" colspan="2">Digite os números abaixo:</td>
</tr>
<tr>
<td align="right" valign="middle" width="60%">
<img id="captcha_image" src="imagens/icon_wait.gif" onclick="javascript: setTextoCaptchaFocus()" align="middle">
</td>
<td width="40%" align="left">
<input type="text" id="captcha_text" name="captcha_text" value="" size="5" maxlength="5" onkeypress="return validaNumeroCaptcha(event);" onkeyup="return verificaNumero(this);" onkeydown="if (popup && (getBrowser() == 'safari' || getBrowser() == 'opera')) return false;" class="campo_form" autocomplete="off">
<div id="wait" style="display: none;"/>
</td>
</tr>
<tr>
<td class="pequeno" align="center" colspan="2">
<a href="javascript: recarregaImagem()" id="gerar">Gerar nova imagem</a> -
<a href="captchaAudio.svl" onclick="javascript: setTextoCaptchaFocus()">Escutar o código</a>
</td>
</tr>
<tr>
<td class="pequeno" align="center" colspan="2">
<br>Caso a imagem não apareça, clique em 'Gerar nova imagem'.
</td>
</tr>
</table>
</body>
When you have forms processing just use CURLOPT_POSTFIELDS, but in this case you do not have, how to proceed?
I don’t understand what you want to do, this page does not submit or request any data... it is just a captcha field?
– Luis Henrique
The page in question is this: www4.tjmg.jus.br/juridico/sf/captcha.jsp In the case after typing the correct captcha the page is in eternal "loop", but allows me to view the query pages without having to type another captcha. Try to access this link anonymously: http://www4.tjmg.jus.br/juridico/sf/proc_resultado_nome.jsp?nomePessoa=NOME_DA_PESSSOA&cpfcnpj=&tipPessoa=X&naturezProcesso=1&situacaoParteA&comCodigo=NUMERO_DA_COMARCA&numero=1 Go ask captcha. Now access the first link of this reply, type the captcha and then access this second, will access normally.
– Diego
Managed to understand @Luishenrique ?
– Diego
Which Curl you already have, nothing?
– Inkeliz
@Inkeliz includes the following files: http://answall.com/questions/114152/tjmg-fazer-busca-em-loop-entre-comarcas-com-curl-e-captcha
– Diego