Estou com problema para pegar informação de um determinado campo através do webclient, segue o código:
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import java.io.IOException;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author felipehts
*/
public class NewMain {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
//definicao do browser
WebClient webClient = new WebClient(BrowserVersion.getDefault());
// página da receita
HtmlPage url = webClient.getPage("http://www.receita.fazenda.gov.br/PessoaJuridica/CNPJ/cnpjreva/Cnpjreva_Solicitacao2.asp");
// pega o form html
HtmlForm form = url.getForms().get(0);
String subm = form.getInputByName("captchaAudio").getNameAttribute();
System.out.println(subm);
}
}
Segue o erro:
29/08/2012 12:22:20 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
AVISO: Obsolete content type encountered: 'application/x-javascript'.
Exception in thread "main" ======= EXCEPTION START ========
EcmaError: lineNumber=[101] column=[0] lineSource=[null] name=[TypeError] sourceName=[script in http://www.receita.fazenda.gov.br/PessoaJuridica/CNPJ/cnpjreva/Cnpjreva_Solicitacao2.asp from (69, 30) to (171, 11)] message=[TypeError: Cannot read property "value" from undefined (script in http://www.receita.fazenda.gov.br/PessoaJuridica/CNPJ/cnpjreva/Cnpjreva_Solicitacao2.asp from (69, 30) to (171, 11)#101)]
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read property "value" from undefined (script in http://www.receita.fazenda.gov.br/PessoaJuridica/CNPJ/cnpjreva/Cnpjreva_Solicitacao2.asp from (69, 30) to (171, 11)#101)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:594)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:537)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:538)
Alguém poderia ajudar ??? vlwww