Java Mailing List Archive

http://www.gg3721.com/

Home » user.groovy »

Re: [groovy-user] HTTP Post/Get

tim.yates

2010-03-11

Replies: Find Java Web Hosting

Author LoginPost Reply
Posting the form on http://www.snee.com/xml/crud/posttest.html with the http-builder package would look something like this:

@Grab( 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.0-RC2' )
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.URLENC

def http = new HTTPBuilder( 'http://www.snee.com/xml/crud/' )
http.post( path:'posttest.cgi',
           body:[ fname:'Tim' , lname:'Yates' ],
           requestContentType:URLENC ) { resp, reader ->
  println "Response status: ${resp.statusLine}"
  System.out << reader
}

That posts the 2 fields on that page, then prints the results

Not used http-builder before though, so there may be a neater way of doing it :-)

Tim


On Thu, Mar 11, 2010 at 5:24 PM, Anders Viklund <viklund_anders@hotmail.com> wrote:
wow!

How to post any contents to the page before read it?


From: tim.yates@gmail.com
Date: Thu, 11 Mar 2010 16:05:25 +0000
To: user@groovy.codehaus.org
Subject: Re: [groovy-user] HTTP Post/Get


new URL( "http://www.google.com" ).text

On Thu, Mar 11, 2010 at 4:02 PM, Anders Viklund <viklund_anders@hotmail.com> wrote:
Hi,

is there a simple way to fetch the contents of a web page using Groovy?

Thanks!


Hotmail: Trusted email with Microsoft’s powerful SPAM protection. Sign up now.



Your E-mail and More On-the-Go. Get Windows Live Hotmail Free. Sign up now.

©2008 gg3721.com - Jax Systems, LLC, U.S.A.