Skip to content

Commit

Permalink
Merge branch 'custom-session' of https://github.com/miracle2k/reppy
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcarp committed Jul 9, 2014
2 parents a55d4f7 + 8a58cd5 commit ef17b71
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion reppy/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class RobotsCache(object):
def __init__(self, *args, **kwargs):
# The provided args and kwargs are used when fetching robots.txt with
# a `requests.get`
self.session = kwargs.pop('session', requests.Session())
self.args = args
self.kwargs = kwargs
# A mapping of hostnames to their robots.txt rules
Expand Down Expand Up @@ -73,7 +74,7 @@ def fetch(self, url, *args, **kwargs):
# First things first, fetch the thing
robots_url = 'http://%s/robots.txt' % Utility.hostname(url)
logger.debug('Fetching %s' % robots_url)
req = requests.get(robots_url, *args, **kwargs)
req = self.session.get(robots_url, *args, **kwargs)
ttl = max(self.min_ttl, Utility.get_ttl(req.headers, self.default_ttl))
# And now parse the thing and return it
return parser.Rules(robots_url, req.status_code, req.content,
Expand Down

0 comments on commit ef17b71

Please sign in to comment.