changeset 93 | 4794759139ea |
parent 92 | e85600529ca5 |
child 96 | 9fcd3de53c06 |
92:e85600529ca5 | 93:4794759139ea |
---|---|
1 val http_pattern = """\"https?://[^\"]*\"""".r |
|
2 |
|
3 def unquote(s: String) = s.drop(1).dropRight(1) |
|
4 |
|
5 def get_all_URLs(page: String) : Set[String] = { |
|
6 (http_pattern.findAllIn(page)).map { unquote(_) }.toSet |
|
7 } |
|
8 |
|
9 def crawl(url: String, n: Int) : Unit = { |
|
10 if (n == 0) () |
|
11 else { |
|
12 println("Visiting: " + n + " " + url) |
|
13 for (u <- get_all_URLs(get_page(url))) crawl(u, n - 1) |
|
14 } |
|
15 } |
|
16 |