"Robo" para cadastro

4 respostas
D

Fala pessoal, vamos ver se podem me ajudar.
Preciso montar um “robo” para logar em um determinado sistema e preencher dados no cadastro em varias paginas.
Alguem ja fez algo do tipo ou tem ideia de como fazer isso.
Andei dando uma olhada no Robot, alguem conhece ele mais a fundo ou indica algo melhor.
Bem pessoal ja vou agradecendo a ajuda de vcs.

Abraço a todos.

4 Respostas

H

Você tem que montar um? Ou tem que utilizar um que já existe?

Para você logar em um site você pode utilizar a classe HttpConnection.

D

Vou precisar montar, pois vai ser um sistema onde o pessoal vai efetuar cadastros, e durante a noite esse "robo" vai inputar os dados em outro sistema.
Encontrei a biblioteca HttpUnit, conhece ela?
Mas em um teste bem basico esta acontecendo um erro que não faço a minima ideia do que pode ser.

A classe que montei para teste:

import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;


public class Webtest {
	
	  public static void main(String[] args) throws Exception {

          WebConversation wc = new WebConversation();

          WebRequest request = new GetMethodWebRequest( "http://www.google.com/" );
          WebResponse response = wc.getResponse( request );

          System.out.println(response.getTitle());
    }

}

E o erro

org.mozilla.javascript.EcmaError: TypeError: Cannot find function attachEvent. (httpunit#2) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3229) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3219) at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3235) at org.mozilla.javascript.ScriptRuntime.typeError1(ScriptRuntime.java:3247) at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3307) at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:1991) at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:2932) at script(httpunit:2) at script(httpunit) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2251) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:161) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:340) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2758) at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:172) at org.mozilla.javascript.Context.evaluateString(Context.java:1132) at com.meterware.httpunit.javascript.ScriptingEngineImpl.runScript(ScriptingEngineImpl.java:92) at com.meterware.httpunit.scripting.ScriptableDelegate.runScript(ScriptableDelegate.java:88) at com.meterware.httpunit.parsing.NekoDOMParser.runScript(NekoDOMParser.java:151) at com.meterware.httpunit.parsing.ScriptFilter.getTranslatedScript(ScriptFilter.java:150) at com.meterware.httpunit.parsing.ScriptFilter.endElement(ScriptFilter.java:131) at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:249) at org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:367) at org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1015) at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:888) at org.cyberneko.html.HTMLScanner$SpecialScanner.scan(HTMLScanner.java:2831) at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:809) at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:478) at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:431) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) at com.meterware.httpunit.parsing.NekoHTMLParser.parse(NekoHTMLParser.java:48) at com.meterware.httpunit.HTMLPage.parse(HTMLPage.java:271) at com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:1301) at com.meterware.httpunit.WebResponse.getFrames(WebResponse.java:1285) at com.meterware.httpunit.WebResponse.getFrameRequests(WebResponse.java:1024) at com.meterware.httpunit.FrameHolder.updateFrames(FrameHolder.java:179) at com.meterware.httpunit.WebWindow.updateFrameContents(WebWindow.java:315) at com.meterware.httpunit.WebClient.updateFrameContents(WebClient.java:526) at com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:201) at com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:183) at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158) at com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:199) at com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:183) at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158) at com.meterware.httpunit.WebClient.getResponse(WebClient.java:122) at Webtest.main(Webtest.java:14) Exception in thread "main" com.meterware.httpunit.ScriptException: Script '(function(){ var b,d,e,f;function g(a,c){if(a.removeEventListener){a.removeEventListener("load",c,false);a.removeEventListener("error",c,false)}else{a.detachEvent("onload",c);a.detachEvent("onerror",c)}}function h(a){f=(new Date).getTime();++d;a=a||window.event;var c=a.target||a.srcElement;g(c,h)}var i=document.getElementsByTagName("img");b=i.length;d=0;for(var j=0,k;j

Vlwwww =)

R

Dá uma olhada no selenium,ele serve pra fazer testes automatizados em paginas,talvez vc consiga adaptar para sua situação.
http://seleniumhq.org/

G

denis_gariglio, vc consegui fazer o seu robot?

estou precisando fazer o mesmo, podemos conversar?

George
[email removido]

Criado 5 de junho de 2012
Ultima resposta 11 de jul. de 2013
Respostas 4
Participantes 4