Last active
December 19, 2015 12:29
-
-
Save egorpe/5954986 to your computer and use it in GitHub Desktop.
Getting a domain age from Wayback Machine with Groovy and Jsoup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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