Skip to content

Commit

Permalink
adding lastmod_filter handling (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
iannesbitt committed Oct 31, 2023
1 parent 3b4f62d commit e2be731
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions soscan/spiders/jsonldspider.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ def from_crawler(cls, crawler, *args, **kwargs):
for s in _cs:
spider.settings.set(s, _cs[s], priority='spider')
spider.logger.info(f'Setting override from {mn_settings}: set {s} to {_cs[s]}')
if s in "lastmod_filter":
spider.lastmod_filter = dateparser.parse(
_cs[s],
settings={"RETURN_AS_TIMEZONE_AWARE": True},
)
return spider

def sitemap_filter(self, entries):
Expand Down Expand Up @@ -123,6 +128,8 @@ def sitemap_filter(self, entries):
if self.lastmod_filter is not None and ts is not None:
if ts > self.lastmod_filter:
yield entry
else:
self.logger.debug(f'lastmod_filter skipping {entry}')
else:
yield entry

Expand Down

0 comments on commit e2be731

Please sign in to comment.