This repository has been archived by the owner on Aug 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using a separate module for the crawlers
- Loading branch information
Felipe Martín
committed
Mar 15, 2013
1 parent
3051009
commit c7998d7
Showing
2 changed files
with
19 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Crawler(object): | ||
"Base crawler class." | ||
urls = [] # List of tuples with regular expression of URLs that the crawler handle | ||
|
||
def do(self, action, url): | ||
try: | ||
method = getattr(self, 'action_%s' % action) | ||
result = method(url) | ||
return result | ||
except AttributeError: | ||
This comment has been minimized.
Sorry, something went wrong. |
||
raise CrawlerActionDoesNotExist('%s: action (%s) does not exist' % (self.__class__.__name__, action)) |
This except is hidding proper code exceptions for showing. NeedFix