progs/crawler1.scala
changeset 101 4758a6155878
parent 99 91145f6d9b0e
child 112 95ee5cc5c05d
--- a/progs/crawler1.scala	Thu Sep 26 10:36:24 2013 +0100
+++ b/progs/crawler1.scala	Thu Sep 26 10:39:23 2013 +0100
@@ -1,8 +1,11 @@
+// A crawler which checks whether there
+// are problems with links in web-pages
+
 import io.Source
 import scala.util.matching.Regex
 import scala.util._
 
-// gets the first ~10K of a page
+// gets the first ~10K of a web-page
 def get_page(url: String) : String = {
   Try(Source.fromURL(url).take(10000).mkString) getOrElse 
     { println(s"  Problem with: $url"); ""}
@@ -11,6 +14,7 @@
 // regex for URLs
 val http_pattern = """\"https?://[^\"]*\"""".r
 
+// drops the first and last character from a string
 def unquote(s: String) = s.drop(1).dropRight(1)
 
 def get_all_URLs(page: String) : Set[String] = {
@@ -32,7 +36,5 @@
 //val startURL = """http://www.inf.kcl.ac.uk/staff/mml/"""
 
 
-// call on the command line 
 crawl(startURL, 2)
 
-crawl("""http://www.inf.kcl.ac.uk/staff/urbanc/bsc-projects-13.html""", 2)