Jsoup code in extension?

Can somebody use this code in an extension?
It would be very useful for an app I am wishing to build

String url = “https://www.google.com/search?q=SearchThis”;

Document document = Jsoup //
.connect(url) //
.userAgent(“Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)”) //

Element divResultStats = document.select(“div#resultStats”).first();
if (divResultStats==null) {
throw new RuntimeException(“Unable to find results stats.”);