app1.scala
author Christian Urban <urbanc@in.tum.de>
Fri, 12 Oct 2012 05:45:48 +0100
changeset 33 92b3e287d87e
parent 2 6e7da958ba8c
permissions -rw-r--r--
slides 4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
b606c9439fa6 new version
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
def get_page(url: String) : String = { 
b606c9439fa6 new version
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
  try {
b606c9439fa6 new version
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
    Source.fromURL(url).take(10000).mkString  
b606c9439fa6 new version
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
  }
b606c9439fa6 new version
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
  catch {
b606c9439fa6 new version
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
    case e => {
b606c9439fa6 new version
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
      println("  Problem with: " + url)
b606c9439fa6 new version
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
      ""
b606c9439fa6 new version
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
    }
b606c9439fa6 new version
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
  }
b606c9439fa6 new version
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
}
b606c9439fa6 new version
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12