save urlToValidate to db
This commit is contained in:
@@ -18,6 +18,7 @@ BLACK_LIST = "BLACK_LIST"
|
||||
ACCEPTED_APPOINTMENT_LIST = "ACCEPTED_APPOINTMENT_LIST"
|
||||
EMAIL_LIST = "EMAIL_LIST"
|
||||
DESTINATION_EMAIL_LIST = "DESTINATION_EMAIL_LIST"
|
||||
LINKS_TO_VALIDATE = "LINKS_TO_VALIDATE"
|
||||
|
||||
|
||||
class MongoDbManager:
|
||||
@@ -199,6 +200,13 @@ class MongoDbManager:
|
||||
collection.find_one_and_update({'_id': id}, {"$set": {"url_validated": state, "validated_at": validated_at}},
|
||||
upsert=False)
|
||||
|
||||
def save_links_to_validate(self, link: str):
|
||||
collection_to_use = self.db[LINKS_TO_VALIDATE]
|
||||
collection_to_use.replace_one(filter={'_id': link, }, replacement={
|
||||
u'url': link
|
||||
},
|
||||
upsert=True)
|
||||
|
||||
|
||||
MONGO_STORE_MANAGER = MongoDbManager()
|
||||
|
||||
|
||||
@@ -197,9 +197,10 @@ def read_mails():
|
||||
if match:
|
||||
url = match.group(0)
|
||||
if need_to_valid_url(url, successful_items):
|
||||
url_validator = LinkValidator(url)
|
||||
print("need to validate url: " + url)
|
||||
executor.submit(url_validator.start_page, params.get_proxy(ProxyType.OXYLABS), True)
|
||||
MONGO_STORE_MANAGER.save_links_to_validate(url)
|
||||
# url_validator = LinkValidator(url)
|
||||
# print("need to validate url: " + url)
|
||||
# executor.submit(url_validator.start_page, params.get_proxy(ProxyType.OXYLABS), False)
|
||||
else:
|
||||
print("do not need to click url --> {}".format(mail.mail_address))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user