save email address
This commit is contained in:
@@ -256,11 +256,12 @@ class MongoDbManager:
|
|||||||
collection.find_one_and_update({'_id': id}, {"$set": {"url_validated": state, "validated_at": validated_at}},
|
collection.find_one_and_update({'_id': id}, {"$set": {"url_validated": state, "validated_at": validated_at}},
|
||||||
upsert=False)
|
upsert=False)
|
||||||
|
|
||||||
def save_links_to_validate(self, link: str):
|
def save_links_to_validate(self, link: str, mail_address: str):
|
||||||
collection_to_use = self.db[LINKS_TO_VALIDATE]
|
collection_to_use = self.db[LINKS_TO_VALIDATE]
|
||||||
updated_at = time.strftime("%H:%M:%S", time.localtime())
|
updated_at = time.strftime("%H:%M:%S", time.localtime())
|
||||||
collection_to_use.replace_one(filter={'_id': link, }, replacement={
|
collection_to_use.replace_one(filter={'_id': link, }, replacement={
|
||||||
u'url': link,
|
u'url': link,
|
||||||
|
u'email': mail_address,
|
||||||
"updated_at": updated_at
|
"updated_at": updated_at
|
||||||
},
|
},
|
||||||
upsert=True)
|
upsert=True)
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ class MailReader():
|
|||||||
print(body)
|
print(body)
|
||||||
if VALIDATION_URL_SUBJECT_fr in subject or VALIDATION_URL_SUBJECT_EN in subject:
|
if VALIDATION_URL_SUBJECT_fr in subject or VALIDATION_URL_SUBJECT_EN in subject:
|
||||||
mail = MailPojo(subject=subject, body=body, from_address=from_address)
|
mail = MailPojo(subject=subject, body=body, from_address=from_address)
|
||||||
|
mail.mail_address = self.login
|
||||||
mail_messages.append(mail)
|
mail_messages.append(mail)
|
||||||
return mail_messages
|
return mail_messages
|
||||||
|
|
||||||
@@ -157,6 +158,7 @@ class MailReader():
|
|||||||
|
|
||||||
|
|
||||||
def need_to_valid_url(url: str, successful_items) -> bool:
|
def need_to_valid_url(url: str, successful_items) -> bool:
|
||||||
|
# return True
|
||||||
if len(successful_items) == 0:
|
if len(successful_items) == 0:
|
||||||
return False
|
return False
|
||||||
print("url is :" + url)
|
print("url is :" + url)
|
||||||
@@ -184,8 +186,8 @@ def need_to_check_email(mail: str, successful_items) -> bool:
|
|||||||
# return True
|
# return True
|
||||||
for item in successful_items:
|
for item in successful_items:
|
||||||
if mail in item.email:
|
if mail in item.email:
|
||||||
|
print("url_validated for {} is {}".format(mail, item.url_validated))
|
||||||
if item.url_validated is not None:
|
if item.url_validated is not None:
|
||||||
print("url_validated for {} is {}".format(mail, item.url_validated))
|
|
||||||
return not item.url_validated
|
return not item.url_validated
|
||||||
else:
|
else:
|
||||||
# if url-validated is none, need to check email
|
# if url-validated is none, need to check email
|
||||||
@@ -200,7 +202,7 @@ def read_mails():
|
|||||||
if is_time_between(time(7, 30), time(19, 30)):
|
if is_time_between(time(7, 30), time(19, 30)):
|
||||||
# get email address
|
# get email address
|
||||||
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
|
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
|
||||||
# mail_address1 = MailAddress(mail="enasremor1973@onet.pl", password=")ozBUE0RjZ8N")
|
mail_address1 = MailAddress(mail="camille.gelais@yahoo.com", password="rporemmflqhoewcd")
|
||||||
# mail_address1 = MailAddress(mail="chenpeijun@aol.com", password="ytifuwguknzifqyb")
|
# mail_address1 = MailAddress(mail="chenpeijun@aol.com", password="ytifuwguknzifqyb")
|
||||||
# # mail_address3 = MailAddress(mail="ciyuexie@aol.com", password="czezlmmyypokdfce")
|
# # mail_address3 = MailAddress(mail="ciyuexie@aol.com", password="czezlmmyypokdfce")
|
||||||
# mail_list = [mail_address1]
|
# mail_list = [mail_address1]
|
||||||
@@ -226,7 +228,7 @@ def read_mails():
|
|||||||
# else:
|
# else:
|
||||||
url = match.group(0)
|
url = match.group(0)
|
||||||
if need_to_valid_url(url, successful_items):
|
if need_to_valid_url(url, successful_items):
|
||||||
MONGO_STORE_MANAGER.save_links_to_validate(url)
|
MONGO_STORE_MANAGER.save_links_to_validate(url, mail.mail_address)
|
||||||
# url_validator = LinkValidator(url)
|
# url_validator = LinkValidator(url)
|
||||||
print("need to validate url: " + url)
|
print("need to validate url: " + url)
|
||||||
# executor.submit(url_validator.start_page, params.get_proxy(ProxyType.OXYLABS), False)
|
# executor.submit(url_validator.start_page, params.get_proxy(ProxyType.OXYLABS), False)
|
||||||
|
|||||||
@@ -43,12 +43,29 @@ class ReserveResultPojo:
|
|||||||
publish_type = source['type']
|
publish_type = source['type']
|
||||||
if publish_type:
|
if publish_type:
|
||||||
publish_type = PublishType[publish_type]
|
publish_type = PublishType[publish_type]
|
||||||
phone = source['phone']
|
if 'phone' in source:
|
||||||
url = source['url']
|
phone = source['phone']
|
||||||
id = source['id']
|
else:
|
||||||
|
phone = ""
|
||||||
|
if 'url' in source:
|
||||||
|
url = source['url']
|
||||||
|
else:
|
||||||
|
url = ""
|
||||||
|
if 'id' in source:
|
||||||
|
id = source['id']
|
||||||
|
else:
|
||||||
|
id = ""
|
||||||
email = source['email']
|
email = source['email']
|
||||||
lastName = source['lastName']
|
if 'lastName' in source:
|
||||||
firstName = source['firstName']
|
lastName = source['lastName']
|
||||||
|
else:
|
||||||
|
lastName = ""
|
||||||
|
|
||||||
|
if 'firstName' in source:
|
||||||
|
firstName = source['firstName']
|
||||||
|
else:
|
||||||
|
firstName = ""
|
||||||
|
|
||||||
result = ReserveResultPojo(type=publish_type, phone=phone,
|
result = ReserveResultPojo(type=publish_type, phone=phone,
|
||||||
url=url, email=email,
|
url=url, email=email,
|
||||||
firstName=firstName, lastName=lastName)
|
firstName=firstName, lastName=lastName)
|
||||||
|
|||||||
Reference in New Issue
Block a user