Skip to content

Instantly share code, notes, and snippets.

@166MMX
Created May 19, 2014 18:54
Show Gist options
  • Save 166MMX/9ef61c2685bc6c6dc1c2 to your computer and use it in GitHub Desktop.
Save 166MMX/9ef61c2685bc6c6dc1c2 to your computer and use it in GitHub Desktop.
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1')
import groovy.json.JsonSlurper
import groovyx.net.http.URIBuilder
def url = buildUrl()
def firstHashCode = fetch(url)
def tenMinutesAsMicroseconds = 10 * 60 * 60 * 1000
for (;firstHashCode == fetch(url);)
{
println 'Result unchanged; retrying in 10 minutes'
sleep(tenMinutesAsMicroseconds)
}
println 'Result changed; exiting'
static URL buildUrl ()
{
def builder = new URIBuilder('http://search.maven.org/')
builder.path = 'solrsearch/select'
builder.query = [
'q': 'g:"org.codehaus.groovy" AND a:"groovy"',
'core': 'gav',
'rows': 200,
'wt': 'json'
]
builder.toString().toURL()
}
static int fetch (URL url)
{
def data = url.text
def json = new JsonSlurper().parseText(data)
HashMap response = json.response
response.hashCode()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment