Skip to content

Instantly share code, notes, and snippets.

@dcsobral
Last active December 30, 2015 21:49
Show Gist options
  • Save dcsobral/7890443 to your computer and use it in GitHub Desktop.
Save dcsobral/7890443 to your computer and use it in GitHub Desktop.
Anternative findLinks for coursera Reactive
def findLinks(body: String): Iterator[String] = {
val document = Jsoup.parse(body)
val links = document.select("a[href]")
for {
link <- links.iterator().asScala
} yield link.attr("href")
}
@slandelle
Copy link

Very similar with Jodd:

def findLinks(body: String): Iterator[String] = {
    val document = new LagartoDOMBuilder().parse(body)
    val links = new NodeSelector(document).select("a[href]")
    for {
        link <- links.iterator
    } yield link.getAttribute("href")
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment