Skip to content

Instantly share code, notes, and snippets.

@eldritchideen
Last active July 20, 2017 04:46
Show Gist options
  • Save eldritchideen/ef9295ff6c2f6aeca24e to your computer and use it in GitHub Desktop.
Save eldritchideen/ef9295ff6c2f6aeca24e to your computer and use it in GitHub Desktop.
Web scraping in Scala with Jsoup
import org.jsoup.Jsoup
import org.jsoup.nodes.Element
import scala.collection.JavaConversions._
System.setProperty("http.proxyHost", "xxx.xxx.xxx")
val doc = Jsoup.connect("http://www.smh.com.au/business/markets/52-week-highs?page=-1").get()
//doc.body()
val elems = doc.select("#content > section > table > tbody > tr > th > a")
val foo = for ( e <- elems) yield e.text
@coarsehorse
Copy link

coarsehorse commented Jun 10, 2017

screenshot_4
It helps:

import scala.collection.JavaConverters._
...
val elems = doc.select("#content > section > table > tbody > tr > th > a").asScala

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