author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Fri, 29 Nov 2013 09:01:08 +0000 | |
changeset 211 | deece8c6cf3a |
parent 97 | 60a3ba90dd53 |
child 254 | dcd4688690ce |
permissions | -rw-r--r-- |
7 | 1 |
val http_pattern = """\"https?://[^\"]*\"""".r |
2 |
val my_urls = """urbanc""".r |
|
3 |
val email_pattern = |
|
4 |
"""([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})""".r |
|
5 |
||
6 |
def crawl(url: String, n: Int) : Unit = { |
|
7 |
if (n == 0) () |
|
8 |
else { |
|
96
9fcd3de53c06
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
9 |
println(s"Visiting: $n $url") |
7 | 10 |
val page = get_page(url) |
11 |
println(email_pattern.findAllIn(page).mkString("\n")) |
|
97
60a3ba90dd53
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
96
diff
changeset
|
12 |
for (u <- get_all_URLs(page)) |
60a3ba90dd53
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
96
diff
changeset
|
13 |
crawl(u, n - 1) |
7 | 14 |
} |
15 |
} |