Skip to content

Instantly share code, notes, and snippets.

@egorpe
Last active December 19, 2015 12:29
Show Gist options
  • Save egorpe/5954986 to your computer and use it in GitHub Desktop.
Save egorpe/5954986 to your computer and use it in GitHub Desktop.
Getting a domain age from Wayback Machine with Groovy and Jsoup
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
def DAYS_IN_YEAR = 365
Document doc = Jsoup.connect("http://wayback.archive.org/web/*/${url}").get()
String date = doc.select("#wbMeta p.wbThis a")[1].attributes().href.split('/')[2]
Date firstIndexDate = Date.parse('yyyyMMddHHmmSS', date)
use(groovy.time.TimeCategory) {
def duration = new Date() - firstIndexDate
println Math.round(duration.days / DAYS_IN_YEAR * 100) / 100
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment