I have a python script that scrubs emails and works well.
I need to add the ability to remove everything including and after the string "Still have questions" after the second def of "removte_http_links" in the following part of the script.
NEW EXPRESSION TO BE PUT IN HERE IN THE PROCESS
I would appreciate any input to accomplish this task in the sequence above.
Thanks in advance.
Mark
I need to add the ability to remove everything including and after the string "Still have questions" after the second def of "removte_http_links" in the following part of the script.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
def extract_http_links(payload): # pattern = r'https?://[^\s<>"]+|www\.[^\s<>"]+' pattern = r 'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+=]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+' http_links = re.findall(pattern, payload) return http_links def remove_http_links(payload): #pattern = r'https?://[^\s<>"]+|www\.[^\s<>"]+' pattern = r '<http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+=<>]|[\r\n]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+' payload_without_links = re.sub(pattern, '', payload) pattern = r 'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+=<>]|[\r\n]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+' payload_without_links = re.sub(pattern, '', payload_without_links) return payload_without_links |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
def send_all_email(message_all , subject): print (subject) print (message_all.encode( 'utf-8' )) msg = MIMEMultipart() msg[ 'From' ] = username msg[ 'To' ] = forward_address # msg['Subject'] = subject msg.attach(MIMEText(message_all)) mail = smtplib.SMTP(smtp_server, smtp_port) mail.ehlo() mail.starttls() mail.ehlo() mail.login(username, password) mail.sendmail(username, forward_address, msg.as_string()) mail.quit() |
Thanks in advance.
Mark