Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132944 views
License: OTHER
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
}
25