http - Java - Interact with website to update information -
so got situation , may have 2 different routes take. thing have update information generate, formatted , parsed , ready displayed. don't know how input txt file (or giant string) site. 1 way find way java interact page, paste info in text area , save/submit update. other way edit page file inserting giant string in place it's supposed go. i've been researching http forms, used third party libraries. have no idea how either route. ive been checking these sites, , other, think complex or need external libraries selenium, , have no experience using urlconnection class. help!
--i don't have control of server, can access it, thinking first idea more practical...
http://kspace.in/blog/2008/05/30/submit-html-form-using-java/
http://www.devcomments.com/q450155/how-to-have-java-application-interact-with-website
use http post:
http://www.exampledepot.com/egs/java.net/post.html
try { // construct data string data = urlencoder.encode("key1", "utf-8") + "=" + urlencoder.encode("value1", "utf-8"); data += "&" + urlencoder.encode("key2", "utf-8") + "=" + urlencoder.encode("value2", "utf-8"); // send data url url = new url("http://hostname:80/cgi"); urlconnection conn = url.openconnection(); conn.setdooutput(true); outputstreamwriter wr = new outputstreamwriter(conn.getoutputstream()); wr.write(data); wr.flush(); // response bufferedreader rd = new bufferedreader(new inputstreamreader(conn.getinputstream())); string line; while ((line = rd.readline()) != null) { // process line... } wr.close(); rd.close(); } catch (exception e) { }
Comments
Post a Comment