def start(): selected_city = selected_job = None events = get_events() for event in events: summary = event['summary'] if summary == "Initial Email": send_initial_email() else: itemtype, itemvalue = summary.split(": ") if itemtype == "City": selected_city = itemvalue if itemtype == "Job": selected_job = itemvalue if selected_city and selected_job: jobs_list = generate_jobs_list(selected_job, selected_city) subject = "Today's top %s jobs for %s in %s: " % ( NUMBER_OF_JOBS_TO_RETURN, selected_job, selected_city) message_body = create_email_jobs_message(jobs_list, NUMBER_OF_JOBS_TO_RETURN) from pprint import pprint pprint(message_body.replace("<br>", "\n")) send_email(email_user, TO_ADDRESSES, subject, message_body, email_user, email_pass)
def send_initial_email(): message_body = """Merry Christmas, and welcome to Gobhunter! You will now receive daily job digests by email from Gobhunter.<br><br> The schedule can be found in another email inviting you to view gobhunter's calendar.<br> You can also modify the schedule yourself by modifying, deleting, or creating new events.<br><br> Guidelines: Each day should only have two events, one starting with "City: ", and another with "Job: "<br> For best results make the events 'whole day' events.<br><br> The default cities are chosen from this link: <a href="http://greatist.com/health/20-best-cities-20-somethings">Best cities for twenty somethings</a>. Extended descriptions for the cities are available there.<br><br> <br>Reply STOP to stop messages. Just kidding, that won't work, just ask Chris to stop the messages.<br> <br>My code can be found on github here. Not my best work, but still pretty cool: https://github.com/maxsparrow/gobhunter<br> """ send_email(email_user, TO_ADDRESSES, "Welcome to Gobhunter!", message_body, email_user, email_pass)
def insert(self): self.name = self.entName.get() self.phone = self.entPhone.get() self.email = self.entEmail.get() self.password = self.entPassword.get() self.db = sqlite3.connect(dbname) print("Connected successfully") self.cursor = self.db.cursor() if len(self.name) != 0: if len(self.phone)!= 0: if len(self.email) != 0: if len(self.password) != 0: if re.match("[^@]+@[^@]+\.[^@]+", self.email): try: self.cursor.execute('''INSERT INTO users(name, phone, email, password) VALUES(?,?,?,?) ''', (self.name, self.phone, self.email, self.password)) print("User Inserted") tkinter.messagebox.showinfo("Success", "User successfully added!") self.entEmail.delete(0, 'end') self.entPassword.delete(0, 'end') self.entPhone.delete(0, 'end') self.entName.delete(0, 'end') self.submitbtn.configure(relief=RAISED) send_email(self.email, self.name) except sqlite3.IntegrityError: print("Email already exists") tkinter.messagebox.showwarning("Error", "An account with this email already exists!") stop = True else: tkinter.messagebox.showwarning("Warning", "You have to enter a valid email address!") else: tkinter.messagebox.showwarning("Warning", "You have to fill all the fields!") else: tkinter.messagebox.showwarning("Warning", "You have to fill all the fields!") else: tkinter.messagebox.showwarning("Warning", "You have to fill all the fields!") else: tkinter.messagebox.showwarning("Warning", "You have to fill all the fields!") self.db.commit() self.cursor.execute("SELECT name FROM users ORDER BY id") self.results = self.cursor.fetchall() print(self.results)
def on_matching_slot_found(): print_success_ascii_art() log.screenshot('free_slots_found') os.system("play ./sms_mario.wav") emailsender.send_email("on_matching_slot_found") # Open browser, log in and search headless = config['tool'].get('headless') openBrowserOnSuccess = config['tool'].get('openBrowserOnSuccess') if headless and openBrowserOnSuccess: log.info('Opening browser') global driver driver = create_driver(False) perform_authentication() fill_in_search_form() submit_search_form() sys.exit(0)
def start(): selected_city = selected_job = None events = get_events() for event in events: summary = event['summary'] if summary == "Initial Email": send_initial_email() else: itemtype, itemvalue = summary.split(": ") if itemtype == "City": selected_city = itemvalue if itemtype == "Job": selected_job = itemvalue if selected_city and selected_job: jobs_list = generate_jobs_list(selected_job, selected_city) subject = "Today's top %s jobs for %s in %s: " % (NUMBER_OF_JOBS_TO_RETURN, selected_job, selected_city) message_body = create_email_jobs_message(jobs_list, NUMBER_OF_JOBS_TO_RETURN) from pprint import pprint pprint(message_body.replace("<br>","\n")) send_email(email_user, TO_ADDRESSES, subject, message_body, email_user, email_pass)
def main(): """Runs all processes for scraping and storing articles""" print("Starting email-trending process...") sections = {'articles': {}} # collect article data for each category, add to sections var for category in CONFIG["reddit"]["categories"]: print(f"\nCollecting data for {category} section...") logging.info(f"Collecting data for {category} section...") reddit = redditinfo.GetRedditInfo( subreddits=CONFIG["reddit"]["categories"][category]["subreddits"], credentials=CONFIG["reddit"]["praw_credentials"], exclude=CONFIG["reddit"]["exclude"], use_ratio=CONFIG["reddit"]["use_ratio"], timeframe=CONFIG["reddit"]["timeframe"], amount=CONFIG["reddit"]["amount"]) top_articles = reddit.get_top_articles(pd_dataframe=True) sections['articles'][category] = [] # add additional blank columns top_articles["keywords"] = "" top_articles["summary"] = "" misc.print_progressbar(0, len(top_articles), prefix="Summarizing articles:") for i, article in top_articles.iterrows(): logging.info(f"Scraping {article['url']}...") try: run = scrapecontent.ScrapeArticle(article['url']) except Exception as e: # catch if article cannot be scraped logging.warning(f"Exception scraping {article['url']}...\n{e}") continue try: content = run.summary() # set values in dataframe top_articles['keywords'].at[i] = content['keywords'] # prepare for html top_articles['summary'].at[i] = content['summary'].replace( "\n", "<br/>").strip() except scrapecontent.SummaryError as e: logging.warning( f"SummaryError scraping {article['url']}...\n{e}") continue # skip if content is blank if top_articles['summary'].at[i].strip() == "": continue # add relevant info to sections dict for email building sections['articles'][category].append({ "title": top_articles['title'].at[i], "link": top_articles['url'].at[i], "content": top_articles['summary'].at[i] }) misc.print_progressbar(i + 1, len(top_articles), prefix="Summarizing articles:") # build the email html logging.debug("Rendering email template") # use the markets section or not print("Building html email template") sections['quote'] = misc.get_quote() if CONFIG["markets"]["run"]: sections['markets'] = [] today = datetime.today() # take 5 days back for weekends and public holidays past = today - timedelta(days=5) for ticker in CONFIG["markets"]["tickers"]: try: temp = securityinfo.get_sec_info( ticker=ticker, start_date=past.strftime("%Y-%m-%d"), end_date=today.strftime("%Y-%m-%d")) except Exception as e: logging.warning(f"Cannot get quote for {ticker}:\n{e}") continue sections['markets'].append({ "ticker": ticker, "price": temp["close"], "change": temp['change_pc'] }) html = renderhtml.get_render(style=CSS_STYLE, sections=sections) # send email logging.debug("Sending email") print("Sending email") emailsender.send_email(sender=CONFIG['email']['sender'], sender_pwd=CONFIG['email']['sender_pwrd'], to_list=CONFIG['email']['to_list'], html_content=html, subject="email-trending")
import sqlite3 import emailsender db = sqlite3.connect('MyFirstSQLApp') cursor = db.cursor() cursor.execute("SELECT email FROM users ORDER BY id") row = cursor.fetchone() while row is not None: emailsender.send_email(str(row[0])) row = cursor.fetchone() db.close() print("Success")
def submit(self, event): name = self.entry1.get() surname = self.entry2.get() password = self.entry4.get() confirm = self.entry5.get() email = self.entry.get() check1 = Path("data/" + email) if check1.is_file(): self.label3.configure(fg="red") self.entry.configure(fg="red") self.label3[ "text"] = "This email address is already registered" else: if not re.match(r"[^@]+@[^@]+\.[^@]+", email): self.entry.configure(fg="red") self.label3["fg"] = "red" self.label3["text"] = "Not valid email address!" else: self.entry.configure(fg="blue") if len(name) == 0: self.entry1.configure(fg="red") self.label3["fg"] = "red" self.label3[ "text"] = "'First name' is a required filed" else: self.entry1.configure(fg="blue") if len(surname) == 0: self.entry2.configure(fg="red") self.label3["fg"] = "red" self.label3[ "text"] = "'Last name' is a required filed" else: self.entry2.configure(fg="blue") if len(password) < 6: self.entry4.configure(fg="red") self.label3["fg"] = "red" self.label3[ "text"] = "The password must contain at least 6 letters" else: if password == confirm: self.entry4.configure(fg="blue") with open("data/" + email, "w+") as out_registration: char = "1" for i in range(len(char)): out_string = str(name + " " + surname + "\n" + email + "\n" + password) out_registration.write(out_string) emailsender.send_email( email, name, surname, password) messagebox.showinfo( title="Welcome", message= "You are successfully registered. \nCheck your e-mail", ) quit() else: self.entry4.configure(fg="red") self.entry5.configure(fg="red") self.label3["fg"] = "red" self.label3[ "text"] = "Passwords do not match"
def on_matching_slot_found(): print_success_ascii_art() log.screenshot('free_slots_found') os.system("play ./sms_mario.wav") emailsender.send_email("on_matching_slot_found") sys.exit(0)
{results_str}\ {random.choice(open("quotes.txt").readlines())}\ Today's weather is expected to be {get_status(zipcode)}. The expected temperature for today is {temperature} degrees fahrenheit. Have a wonderful day! """ html = f"""\ <html> <body> <p>Hi,<br> <br> These are the {choice} daily headlines:<br> <br> {results_str} {random.choice(open("quotes.txt").readlines())} <br> <br> Today's weather is expected to be {get_description(zipcode)}. The expected temperature for today is {temperature} degrees fahrenheit. Have a wonderful day! </p> </body> </html> """ message["Subject"] = "Daily Weather and {} Headlines".format(capitalChoice) part1 = MIMEText(text, "plain") part2 = MIMEText(html, "html") message.attach(part1) message.attach(part2) context = ssl.create_default_context() send_email(sender_email, receiver_email, message, password)