Advertisement
themoosemind

weather.scala

Mar 10th, 2014
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.60 KB | None | 0 0
  1. import scala.io._
  2. import scala.xml.{Source => Source2, _}
  3. import scala.actors._
  4. import Actor._
  5.  
  6. def getWeatherInfo(woeid: String) = {
  7.     val url = "http://weather.yahooapis.com/forecastrss?w=" + woeid
  8.     val response = Source.fromURL(url).mkString
  9.     val xmlResponse = XML.loadString(response)
  10.     println(xmlResponse \\ "location" \\ "@city",
  11.         xmlResponse \\ "condition" \\ "@temp")
  12. }
  13.  
  14. val caller = self
  15.  
  16. for(id <- 2391271 to 2391279) {
  17.     actor{ getWeatherInfo(id.toString) }
  18. }
  19.  
  20. for(id <- 2391271 to 2391279) {
  21.     receiveWithin(5000) {
  22.         case msg => println(msg)
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement