Commit 3c67ade8 authored by Vasyl Bodnaruk's avatar Vasyl Bodnaruk

Add flag fresh for rescrap all news or only fresh

parent 3ec3ca57
...@@ -7,9 +7,10 @@ db = Database(**db_settings) ...@@ -7,9 +7,10 @@ db = Database(**db_settings)
class BaseSpider(scrapy.Spider): class BaseSpider(scrapy.Spider):
def __init__(self, query=None, *args, **kwargs): def __init__(self, query=None, fresh=True, *args, **kwargs):
super(BaseSpider, self).__init__(*args, **kwargs) super(BaseSpider, self).__init__(*args, **kwargs)
self.condition = query self.condition = query
self.fresh = False if fresh == 'False' else True
self.query = "SELECT id, name, country FROM wp_esi_entity WHERE 1 and id=3" self.query = "SELECT id, name, country FROM wp_esi_entity WHERE 1 and id=3"
if self.condition: if self.condition:
print(self.condition) print(self.condition)
...@@ -25,7 +26,7 @@ class BaseSpider(scrapy.Spider): ...@@ -25,7 +26,7 @@ class BaseSpider(scrapy.Spider):
return companies.get_companies() return companies.get_companies()
def can_follow(self, next_url, duplicate): def can_follow(self, next_url, duplicate):
if next_url and not duplicate: if (next_url and not duplicate) or self.fresh is False:
return True return True
else: else:
return False return False
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment