How to get the servlet response html code

1

good afternoon engineers, I need to catch the html code of a servlet to be able to show only fragments of information, I do not pretend to modify any content, much less affect, I just need to show specific information, I attached an example image of how I show the servlet inside an iframe.

this is the link of my page already on the server: link

I tried to trap the html with ajax using this code but it does not throw the code of the image but another, I attach the code:

 var valCaptch = $("#captcha").val();
        var valPlaca = $("#placa").val();
        var valUrl = "http://www2.repuve.gob.mx:8080/ciudadania/servletconsulta"
        var valUrlfinal = valUrl + "?" + "placa=" + valPlaca + "&vin=" + "&folio=" + "&nrpv =" + "&captcha=" + valCaptch;

$.ajax({
            type: "POST",
            cache: false,
            url: valUrlfinal,
            data: { placa: valPlaca, captcha: valCaptch },
            error : errors,
            dataType: 'jsonp',
            success: success
        });

I hope you can help me

    
asked by gustavo aguilar 05.01.2017 в 22:55
source

1 answer

1

On the web pages there is server code and client code. The server code is executed before sending you the data, then you receive it in the browser and then the client code (javascript) is processed. What is happening to you is that the re-captcha is not processed from the server, only the script arrives that, once the page has arrived at your browser, will be executed.

That said, the only way you can get that image is to let the client code be processed once you've received it in a container like an iFrame, and then use a library to help you look for DOM elements (which are nothing more than HTML tags) like jQuery to find the image that was generated at the end.

This is not a 100% secure solution, since you do not know how that re-captcha is generated, it is possible that it comes in base 64, so you should read the content instead of downloading the image. You may change it dynamically, it may be on a canvas, etc. Especially with re-captchas that are precisely designed to avoid automated processes, it can be complicated.

    
answered by 06.01.2017 в 01:08