progs/crawler1.scala
changeset 95 dbe49327b6c5
parent 93 4794759139ea
child 96 9fcd3de53c06
--- a/progs/crawler1.scala	Wed Aug 07 17:31:42 2013 +0100
+++ b/progs/crawler1.scala	Tue Sep 24 01:12:36 2013 +0100
@@ -7,8 +7,8 @@
     Source.fromURL(url).take(10000).mkString  
   }
   catch {
-    case e => {
-      println("  Problem with: " + url)
+    case _ : Throwable => {
+      println(s"  Problem with: $url")
       ""
     }
   }
@@ -29,7 +29,7 @@
 def crawl(url: String, n: Int) : Unit = {
   if (n == 0) ()
   else {
-    println("Visiting: " + n + " " + url)
+    println(s"Visiting: $n $url")
     for (u <- get_all_URLs(get_page(url))) crawl(u, n - 1)
   }
 }
@@ -42,4 +42,4 @@
 // call on the command line 
 crawl(startURL, 2)
 
-crawl("""http://www.dcs.kcl.ac.uk/staff/urbanc/msc-projects-12.html""", 2)
+crawl("""http://www.inf.kcl.ac.uk/staff/urbanc/bsc-projects-13.html""", 2)