Merge remote-tracking branch 'origin/master'

This commit is contained in:
2023-01-05 16:00:52 +01:00
8 changed files with 42 additions and 70 deletions
+3 -1
View File
@@ -233,8 +233,10 @@ class MongoDbManager:
def save_links_to_validate(self, link: str):
collection_to_use = self.db[LINKS_TO_VALIDATE]
updated_at = time.strftime("%H:%M:%S", time.localtime())
collection_to_use.replace_one(filter={'_id': link, }, replacement={
u'url': link
u'url': link,
"updated_at": updated_at
},
upsert=True)
-46
View File
@@ -70,23 +70,6 @@ class InvoiceGetter():
mails_messages.extend(mail_list)
return mail_list
# def downloadAllAttachmentsInInbox(self, imap):
# typ, items = imap.search(None, '(SUBJECT "{}" SINCE "{}")'.format(INVOICE_SUBJECT_fr,
# datetime.datetime.today().strftime(
# date_format)))
# items = items[0].split()
# self.downloaAttachmentsInEmail(imap, "./")
#
# def downloaAttachmentsInEmail(self, imap, outputdir):
# resp, data = imap.fetch(HERMES_INVOICE_EMAIL, "(BODY.PEEK[])")
# email_body = data[0][1]
# mail = email.message_from_string(email_body)
# if mail.get_content_maintype() != 'multipart':
# return
# for part in mail.walk():
# if part.get_content_maintype() != 'multipart' and part.get('Content-Disposition') is not None:
# open(outputdir + '/' + part.get_filename(), 'wb').write(part.get_payload(decode=True))
def _get_messages_from_folder(self, imap, subject, folder="INBOX") -> list:
imap.select(folder)
mail_messages = []
@@ -141,36 +124,7 @@ class InvoiceGetter():
return mail_messages
def clean(text):
# clean text for creating a folder
return "".join(c if c.isalnum() else "_" for c in text)
def need_to_valid_url(url: str, successful_items) -> bool:
if len(successful_items) == 0:
return False
print("url is :" + url)
parts = url.split('/')
id = parts[5]
if len(id) == 6:
for item in successful_items:
# if item.url_validated is not None:
# print("id:{}, status:{} ".format(id, str(item.url_validated)))
if item.id == id:
if item.url_validated is not None:
return not item.url_validated
else:
# if url_validated is None
return True
# return True by default
return False
else:
print("id not valid:{}".format(id))
return False
def get_invoices():
# check time before start checking emails
# get email address
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
mail_list_to_check = []
+4 -9
View File
@@ -131,11 +131,6 @@ class MailReader():
return mail_messages
def clean(text):
# clean text for creating a folder
return "".join(c if c.isalnum() else "_" for c in text)
def need_to_valid_url(url: str, successful_items) -> bool:
if len(successful_items) == 0:
return False
@@ -167,7 +162,7 @@ def need_to_check_email(mail: str, successful_items) -> bool:
for item in successful_items:
if mail in item.email:
if item.url_validated is not None:
print("url_validated for {} is {}".format(item.url_validated, mail))
print("url_validated for {} is {}".format(mail, item.url_validated))
return not item.url_validated
else:
# if url-validated is none, need to check email
@@ -205,10 +200,10 @@ def read_mails():
if match:
url = match.group(0)
if need_to_valid_url(url, successful_items):
# MONGO_STORE_MANAGER.save_links_to_validate(url)
url_validator = LinkValidator(url)
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), True)
# executor.submit(url_validator.start_page, params.get_proxy(ProxyType.OXYLABS), False)
else:
print("do not need to click url --> {}".format(mail.mail_address))
+15 -6
View File
@@ -10,13 +10,22 @@ api_secret = "edac41f0e1726ba49808dfb12204ecd6"
mailjet = Client(auth=(api_key, api_secret), version='v3.1')
from_email = "no-reply@lpaconsulting.fr"
# store = "Hermès Paris Faubourg"
store = "Hermès Paris Sèvres"
# store = "Hermès Paris George V"
# dest_email = "0429xiaohan@gmail.com" #小萝卜
# dest_email = "1340219934@qq.com" #小于
store = "Hermès Paris George V"
# store = "Hermès Paris Sèvres"
# dest_email = "928490803@qq.com"
# dest_email = "1757344572@qq.com"
# dest_email = "392417782@qq.com"
# dest_email = "linghuili@hotmail.com"
dest_email = "landdu@outlook.com"
contact_name = "LI Jiaxi"
# dest_email = "fanfan19810617@icloud.com"
# dest_email = "fanchunying323@163.com"
# dest_email = "lytlaure@gmail.com"
dest_email = "arianezhangsn@yahoo.com"
# dest_email = "sunrose75015@gmail.com"
# dest_email = "1340219934@qq.com"
# dest_email = "lytlaure@gmail.com"
# dest_email = "m13805869912@163.com"
# dest_email = "tangliang0411@gmail.com"
contact_name = "LU yaping"
f = open(config.ROOT_DIR + "/templates/confirmed_rdv.html", "r")
email_body = f.read()
+1 -2
View File
@@ -97,7 +97,7 @@ class CommandorPage:
self.otp_value = None
# device = None
device_key = random.choice(params.DEVICES)
device_key = random.sample(list(self.tls.playwright.devices), 1)[0]
# device_key = random.sample(list(self.tls.playwright.devices), 1)[0]
device = self.tls.playwright.devices[device_key]
# while device is None:
# device_key = random.sample(list(self.tls.playwright.devices), 1)[0]
@@ -417,7 +417,6 @@ class CommandorPage:
def handle_captcha_error(self):
MONGO_STORE_MANAGER.insert_captcha_error_contact(self.contact)
params.oracle_log_sender.send_captcha_error(self.contact)
def check_is_blocked(self) -> bool:
iframe = self.page.query_selector('iframe').content_frame()