I'm working on a grails app and for several hours already have been trying to get html code from a request. What I want to do is to get plain html (like in a webPage source, with all tags and stuff), so that i can work on that.
I have already managed to get it for my get requests with this code:
url = ("http://google.com").toURL().getText())
It works just fine, but I also need to be able to make post requests.
I've tried with httpBuilder, but the response I'm getting looks like well formated text (with white spaces and stuff), but that hasn't got any html tags, and I need them. Code I'm using looks like this:
def url = "http://urlToRemoteServer.com/"
def http = new HTTPBuilder(url);
http.post( path: 'pathToMyApp',
requestContentType: "text/xml" ) { resp, reader ->
println "Tweet response status: ${resp.statusLine}"
assert resp.statusLine.statusCode == 200
System.out << reader
}
Can anyone tell me how to get that html code? I'm working on groovy, but Java solution will be just as good.