change contact start end number
This commit is contained in:
+27
-31
@@ -9,7 +9,7 @@ from builtins import list
|
||||
|
||||
from src import params
|
||||
from src.db.mongo_manager import MONGO_STORE_MANAGER
|
||||
from src.pojo.mail.mail_pojo import MailPojo
|
||||
from src.pojo.mail.mail_pojo import MailPojo, MailAddress
|
||||
from src.proxy.proxy_type import ProxyType
|
||||
from src.workers.link_validator import LinkValidator
|
||||
|
||||
@@ -28,7 +28,7 @@ class MailReader():
|
||||
mail_list = []
|
||||
imap = imaplib.IMAP4_SSL(AOL_IMAP_SERVER)
|
||||
# authenticate
|
||||
imap.login(self.login, password)
|
||||
imap.login(self.login, self.password)
|
||||
status, messages = imap.select("INBOX")
|
||||
# total number of emails
|
||||
messages = int(messages[0])
|
||||
@@ -51,8 +51,8 @@ class MailReader():
|
||||
from_address, subject_encoded = decode_header(msg.get("From"))[0]
|
||||
if isinstance(from_address, bytes):
|
||||
from_address = from_address.decode(subject_encoded)
|
||||
print("Subject:", subject)
|
||||
print("From:", from_address)
|
||||
print("Subject:", subject)
|
||||
# if the email message is multipart
|
||||
if msg.is_multipart():
|
||||
# iterate over email parts
|
||||
@@ -81,16 +81,8 @@ class MailReader():
|
||||
|
||||
hermes_email = "no-reply@hermes.com"
|
||||
# account credentials
|
||||
# username = "appointment2022@aol.com"
|
||||
# password = "gyilpmvyyvlcaviq"
|
||||
|
||||
|
||||
username = "chenpeijun@aol.com"
|
||||
password = "ytifuwguknzifqyb"
|
||||
# #
|
||||
#
|
||||
# username = "ciyuexie@aol.com"
|
||||
# password = "czezlmmyypokdfce"
|
||||
username = "appointment2022@aol.com"
|
||||
password = "gyilpmvyyvlcaviq"
|
||||
|
||||
|
||||
def clean(text):
|
||||
@@ -121,21 +113,25 @@ def need_to_valid_url(url: str, successful_items) -> bool:
|
||||
|
||||
# check whether the url has already been clicked
|
||||
if __name__ == '__main__':
|
||||
mail_reader = MailReader(username, password)
|
||||
successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
||||
list = mail_reader.read_emails()
|
||||
with ThreadPoolExecutor(max_workers=10) as executor:
|
||||
for mail in list:
|
||||
match = re.search(VALIDATION_URL_REGEX, mail.body)
|
||||
if match:
|
||||
url = match.group(0)
|
||||
if need_to_valid_url(url, successful_items):
|
||||
url_validator = LinkValidator(url)
|
||||
print("need to validate url: " + url)
|
||||
# .start_page(params.get_proxy(ProxyType.BRIGHT_DATA))
|
||||
executor.submit(url_validator.start_page, params.get_proxy(ProxyType.BRIGHT_DATA))
|
||||
else:
|
||||
print("do not need to click url --> {}".format(mail))
|
||||
|
||||
# find link from mails
|
||||
print(list)
|
||||
mail_address1 = MailAddress(mail="appointment2022@aol.com", password="gyilpmvyyvlcaviq")
|
||||
mail_address2 = MailAddress(mail="chenpeijun@aol.com", password="ytifuwguknzifqyb")
|
||||
mail_address3 = MailAddress(mail="ciyuexie@aol.com", password="czezlmmyypokdfce")
|
||||
mail_address4 = MailAddress(mail="hongjiang176@aol.com", password="ftzpscgzvwneelmn")
|
||||
mail_list = [mail_address3, mail_address2, mail_address1, mail_address4]
|
||||
# mail_list = [mail_address4]
|
||||
for mail in mail_list:
|
||||
mail_reader = MailReader(mail.mail, mail.password)
|
||||
successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
||||
list = mail_reader.read_emails()
|
||||
with ThreadPoolExecutor(max_workers=10) as executor:
|
||||
for mail in list:
|
||||
match = re.search(VALIDATION_URL_REGEX, mail.body)
|
||||
if match:
|
||||
url = match.group(0)
|
||||
if need_to_valid_url(url, successful_items):
|
||||
url_validator = LinkValidator(url)
|
||||
print("need to validate url: " + url)
|
||||
# .start_page(params.get_proxy(ProxyType.BRIGHT_DATA))
|
||||
executor.submit(url_validator.start_page, params.get_proxy(ProxyType.BRIGHT_DATA), True)
|
||||
else:
|
||||
print("do not need to click url --> {}".format(mail))
|
||||
|
||||
@@ -81,7 +81,8 @@ class LinkValidator:
|
||||
self.browser.close()
|
||||
return None
|
||||
|
||||
def start_page(self, proxy):
|
||||
def start_page(self, proxy, headless=False):
|
||||
self.headless = headless
|
||||
self._run(proxy)
|
||||
|
||||
def _on_page_loaded(self):
|
||||
|
||||
Reference in New Issue
Block a user