def grep(self, pattern, url, depth = -1): if depth is -1: depth = self.depth elif depth is 0 or not url or url in self.visited: return self.visited.append(url) f = FileParser(url) matches = f.search(pattern) if len(matches) > 0: print url + ':' for i in matches: print " ", i if depth > 1: for i in f.outlinks(): self.grep(pattern, i, depth - 1)