author | Christian Urban <urbanc@in.tum.de> |
Tue, 25 Sep 2018 00:27:06 +0100 | |
changeset 559 | db5cb071644d |
parent 254 | dcd4688690ce |
permissions | -rw-r--r-- |
559 | 1 |
val my_urls = """urban""".r |
7 | 2 |
|
3 |
def crawl(url: String, n: Int) : Unit = { |
|
4 |
if (n == 0) () |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
5 |
else if (my_urls.findFirstIn(url) == None) { |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
6 |
println(s"Visiting: $n $url") |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
7 |
get_page(url); () |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
8 |
} |
7 | 9 |
else { |
96
9fcd3de53c06
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
10 |
println(s"Visiting: $n $url") |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
11 |
for (u <- get_all_URLs(get_page(url))) crawl(u, n - 1) |
7 | 12 |
} |
13 |
} |