Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
items match {
case Some(items: List[Element]) => {
items.foreach(item => {
val house = House()
val address = item >?> element("[itemprop=address]")
address match {
case None => //
case Some(addressElm) => {
addressElm >?> element("[itemprop=streetAddress]") match {
case None => //
case Some(streetElm) => {
house.street = streetElm.text
}
}
addressElm >?> element("[itemprop=postalCode]") match {
case None => //
case Some(postalElm) => {
house.postalCode = postalElm.text
}
}
}
}
val geo = item >?> element("[itemprop=geo]")
geo match {
case None => //
case Some(geoElm) => {
geoElm >?> element("[itemprop=latitude]") match {
case None => //
case Some(latitudeElm) => {
house.lat = latitudeElm.attr("content")
}
}
geoElm >?> element("[itemprop=longitude]") match {
case None => //
case Some(longElm) => {
house.lng = longElm.attr("content")
}
}
}
}
val price = item >?> element(".zsg-photo-card-price")
price match {
case None => //
case Some(priceElm) => {
house.price = priceElm.text.replace(",", "")
}
}
houses = houses :+ house
})
}
case None => // nothing
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment