MCPcopy Create free account
hub / github.com/ActiveState/code / main

Function main

recipes/Python/576551_Simple_Web_Crawler/recipe-576551.py:163–187  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

161 return opts, args
162
163def main():
164 opts, args = parse_options()
165
166 url = args[0]
167
168 if opts.links:
169 getLinks(url)
170 raise SystemExit, 0
171
172 depth = opts.depth
173
174 sTime = time.time()
175
176 print "Crawling %s (Max Depth: %d)" % (url, depth)
177 crawler = Crawler(url, depth)
178 crawler.crawl()
179 print "\n".join(crawler.urls)
180
181 eTime = time.time()
182 tTime = eTime - sTime
183
184 print "Found: %d" % crawler.links
185 print "Followed: %d" % crawler.followed
186 print "Stats: (%d/s after %0.2fs)" % (
187 int(math.ceil(float(crawler.links) / tTime)), tTime)
188
189if __name__ == "__main__":
190 main()

Callers 1

recipe-576551.pyFile · 0.70

Calls 6

crawlMethod · 0.95
getLinksFunction · 0.85
CrawlerClass · 0.85
parse_optionsFunction · 0.70
timeMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected