2
I am trying to get the data of an electronic invoice through a post on the farm site. I am using the Jsoup library.
First I did a get to get the captcha image and it worked perfectly. I created my screen with inputs for key nfe and catcha and when I submit the form I call the post routine to get the note data.
Only in this post only brings the error page, stating invalid captcha code.
Follow the GET code:
URL_GET = http://www.nfe.fazenda.gov.br/portal/consulta.aspx?tipoConsulta=completa&tipoConteudo=XbSeqxE8pl8=
Document doc = Jsoup.connect(URL_GET).get();
String imgCaptcha = doc.select("#ContentPlaceHolder1_imgCaptcha").attr("src");
Follow the code of the POST:
URL_POST = http://www.nfe.fazenda.gov.br/portal/consulta.aspx?tipoConsulta=completa&tipoConteudo=XbSeqxE8pl8%3d
doc = Jsoup.connect(URL_POST)
.data("__EVENTTARGET", "")
.data("__EVENTARGUMENT", "")
.data("__VIEWSTATE", dados.getViewState())
.data("__EVENTVALIDATION", dados.getEventValidation())
.data("ctl00$txtPalavraChave", "")
.data("ctl00$ContentPlaceHolder1$txtChaveAcessoCompleta", dados.getChaveAcesso())
.data("ctl00$ContentPlaceHolder1$txtCaptcha", dados.getImgCaptcha())
.data("ctl00$ContentPlaceHolder1$btnConsultar", "Continuar")
.data("ctl00$ContentPlaceHolder1$token", dados.getToken())
.data("ctl00$ContentPlaceHolder1$captchaSom", dados.getCaptchaSom())
.data("hiddenInputToUpdateATBuffer_CommonToolkitScripts", "1")
.userAgent("Mozilla")
.post();
The data (__VIEWSTATE and __EVENTVALIDATION) I take from GET and throw in the POST. The other data is default and the key and captcha recover from what the user has reported...
Someone has done something similar?
Did you check if in the POST made by the site only have these parameters? And cookies, including the session?
– Wakim
From what I saw these are all parameters. I have not used cookies!
– Sérgio Danilo