app4.scala
changeset 13 6d554a18b81e
parent 7 73cf4406b773
equal deleted inserted replaced
12:4093d547c011 13:6d554a18b81e
     3 val email_pattern = 
     3 val email_pattern = 
     4   """([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})""".r
     4   """([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})""".r
     5 
     5 
     6 def crawl(url: String, n: Int) : Unit = {
     6 def crawl(url: String, n: Int) : Unit = {
     7   if (n == 0) ()
     7   if (n == 0) ()
     8   //else if (my_urls.findFirstIn(url) == None) ()
       
     9   else {
     8   else {
    10     println("Visiting: " + n + " " + url)
     9     println("Visiting: " + n + " " + url)
    11     val page = get_page(url)
    10     val page = get_page(url)
    12     println(email_pattern.findAllIn(page).mkString("\n"))
    11     println(email_pattern.findAllIn(page).mkString("\n"))
    13     for (u <- get_all_URLs(page)) crawl(u, n - 1)
    12     for (u <- get_all_URLs(page)) crawl(u, n - 1)