--- a/progs/crawler3.scala Tue Sep 20 12:47:46 2016 +0100
+++ b/progs/crawler3.scala Fri Sep 23 15:22:33 2016 +0100
@@ -6,13 +6,13 @@
import scala.util._
def get_page(url: String) : String = {
- Try(Source.fromURL(url).take(10000).mkString) getOrElse
+ Try(Source.fromURL(url)("ISO-8859-1").take(10000).mkString) getOrElse
{ println(s" Problem with: $url"); ""}
}
// regexes for URLs, for "my" domain and for email addresses
val http_pattern = """"https?://[^"]*"""".r
-val email_pattern = """([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})""".r (*@\label{emailline}@*)
+val email_pattern = """([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})""".r /*@\label{emailline}@*/
def unquote(s: String) = s.drop(1).dropRight(1)
@@ -27,7 +27,7 @@
else {
println(s"Visiting: $n $url")
val page = get_page(url)
- print_str(email_pattern.findAllIn(page).mkString("\n")) (*@\label{mainline}@*)
+ print_str(email_pattern.findAllIn(page).mkString("\n")) /*@\label{mainline}@*/
for (u <- get_all_URLs(page).par) crawl(u, n - 1)
}
}