# -*- coding: utf-8 -*- from requests import get from bs4 import BeautifulSoup import time import Foundation import objc NSUserNotification = objc.lookUpClass('NSUserNotification') NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter') def notify(title, subtitle, info_text, delay=0, sound=False, userInfo={}): notification = NSUserNotification.alloc().init() notification.setTitle_(title) notification.setSubtitle_(subtitle) notification.setInformativeText_(info_text) notification.setUserInfo_(userInfo) if sound: notification.setSoundName_("NSUserNotificationDefaultSoundName") notification.setDeliveryDate_(Foundation.NSDate.dateWithTimeInterval_sinceDate_(delay, Foundation.NSDate.date())) NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification) oval = 0 while True: val = int(BeautifulSoup(get('https://www.kickstarter.com/projects/214379695/micropython-on-the-esp8266-beautifully-easy-iot').text, 'html.parser').find_all('data')[2]['data-value']) if val != oval: notify('MicroPython donation!', 'Now at: {} pounds'.format(val), 'Somebody donated {} pounds'.format(val - oval), sound = True) oval = val time.sleep(60)