MCPcopy Index your code
hub / github.com/clips/pattern / __init__

Method __init__

pattern/web/__init__.py:3107–3125  ·  view source on GitHub ↗

A crawler can be used to browse the web in an automated manner. It visits the list of starting URLs, parses links from their content, visits those, etc. - Links can be prioritized by overriding Crawler.priority(). - Links can be ignored by overriding Crawler.foll

(self, links=[], domains=[], delay=20.0, parser=HTMLLinkParser().parse, sort=FIFO)

Source from the content-addressed store, hash-verified

3105class Crawler(object):
3106
3107 def __init__(self, links=[], domains=[], delay=20.0, parser=HTMLLinkParser().parse, sort=FIFO):
3108 """ A crawler can be used to browse the web in an automated manner.
3109 It visits the list of starting URLs, parses links from their content, visits those, etc.
3110 - Links can be prioritized by overriding Crawler.priority().
3111 - Links can be ignored by overriding Crawler.follow().
3112 - Each visited link is passed to Crawler.visit(), which can be overridden.
3113 """
3114 self.parse = parser
3115 self.delay = delay # Delay between visits to the same (sub)domain.
3116 self.domains = domains # Domains the crawler is allowed to visit.
3117 self.history = {} # Domain name => time last visited.
3118 self.visited = {} # URLs visited.
3119 self._queue = [] # URLs scheduled for a visit: (priority, time, Link).
3120 self._queued = {} # URLs scheduled so far, lookup dictionary.
3121 self.QUEUE = 10000 # Increase or decrease according to available memory.
3122 self.sort = sort
3123 # Queue given links in given order:
3124 for link in (isinstance(links, basestring) and [links] or links):
3125 self.push(link, priority=1.0, sort=FIFO)
3126
3127 @property
3128 def done(self):

Callers

nothing calls this directly

Calls 2

pushMethod · 0.95
HTMLLinkParserClass · 0.85

Tested by

no test coverage detected