def main(site, src_user, src_pwd, dest): # grab the page uf = urllib.request.urlopen(site) html = uf.read() # parse the page for desired data soup = BeautifulSoup(html, "html.parser") rate_info = grab_mortgage_rate(soup) print(rate_info) # create message to send (empty body) msg = EmailMessage() msg['Subject'] = rate_info msg['From'] = src_user msg['To'] = dest # send message in e-mail to self mail_butler = EmailHelper() mail_butler.login(src_user, src_pwd) mail_butler.send(src_user, dest, msg) mail_butler.close()
# another instance is running print('Alredy running!') sys.exit(1) PREVIEW_URL = "https://ethwallpaper.co/preview/" IMAGES_PATH = "../backend/static/wallpapers/" images = [] dir_path = os.path.dirname(os.path.realpath(__file__)) config = ConfigParser() config_path = os.path.join(dir_path, '../config.ini') config_path = os.path.normpath(config_path) config.read(config_path) pgconfig = {} email_client = EmailHelper(config['sendgrid']['api_key']) for param in config.items('postgresql'): pgconfig[param[0]] = param[1] # Connect to an existing database conn = psycopg2.connect(**pgconfig) cur = conn.cursor() cur.execute( "SELECT id, ext, logo_size, author_email FROM api_wallpaper WHERE status='Pending';" ) images_done = [] while True: