--- a/progs/crawler1.scala Tue Sep 24 01:12:36 2013 +0100
+++ b/progs/crawler1.scala Tue Sep 24 01:56:53 2013 +0100
@@ -1,18 +1,11 @@
import io.Source
import scala.util.matching.Regex
+import scala.util._
// gets the first ~10K of a page
-def get_page(url: String) : String = {
- try {
- Source.fromURL(url).take(10000).mkString
- }
- catch {
- case _ : Throwable => {
- println(s" Problem with: $url")
- ""
- }
- }
-}
+def get_page(url: String) : String =
+ Try(Source.fromURL(url).take(10000).mkString) getOrElse
+ { println(s" Problem with: $url"); ""}
// regex for URLs