Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions crawler/src/crawler/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ class Crawler(object):
def __init__(self, url, delay, ignore):
self.url = url
self.delay = delay
if ignore:
self.ignore = ignore.split(',')
else:
self.ignore = []
self.ignore = ignore.split(',') if ignore else []
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Crawler.__init__ refactored with the following changes:


def get(self, url):
"""
Expand All @@ -59,10 +56,7 @@ def crawl(self):
for tag in soup.findAll('a', href=True):
link = tag['href']
parsed = urlparse(link)
if parsed.scheme:
to_get = link
else:
to_get = self.url + link
to_get = link if parsed.scheme else self.url + link
Comment on lines -62 to +59
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Crawler.crawl refactored with the following changes:

if should_ignore(self.ignore, to_get):
print('Ignoring URL: {url}'.format(url=to_get))
continue
Expand Down
5 changes: 1 addition & 4 deletions crawler/src/crawler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ def log(url, status):
:param status: A status code for the `Response`.

"""
if 200 <= int(status) < 300:
prose = 'OK'
else:
prose = 'ERR'
prose = 'OK' if 200 <= int(status) < 300 else 'ERR'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function log refactored with the following changes:

print("{prose}: {status} {url}".format(prose=prose, url=url, status=status))


Expand Down