-
Notifications
You must be signed in to change notification settings - Fork 0
SSL
Philip Ford edited this page Apr 24, 2017
·
4 revisions
Using the HTTPBuilder library, which appears to be dead now.1
@Grab( 'org.ccil.cowan.tagsoup:tagsoup:1.2.1' )
@Grab( 'org.codehaus.groovy.modules.http-builder:http-builder:0.7' )
import org.ccil.cowan.tagsoup.Parser
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.*
// Using an https url
new HTTPBuilder( 'https://twitter.com' ).with {
// Get from the given path as TEXT
get( path:'/philip_ford', contentType:TEXT ) { resp, reader ->
// Pass the html through tagsoup and generate a parser
new XmlParser( new Parser() ).parseText( reader.text ).with {
// print the title text from inside the head section
println head.title.text()
}
}
}- Using HTTPBuilder, I received RuntimeExceptions stating that commons-lang:2.4 could not be downloaded. I resolved these by both deleting commons-lang from ~/.m2 and deleting ~/.groovy/grapes. See this article for more information.