Created
March 23, 2013 12:59
-
-
Save iamsilvio/5227648 to your computer and use it in GitHub Desktop.
quick and dirty prowl push with proxy (keep care to specify a real exception to catch and log if needed)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import urllib2 | |
API_URL = 'https://api.prowlapp.com/publicapi/add' | |
API_KEY = 'xxxxxxxxxxxxxxxxxxx' | |
PROXY = 'xxx.xxx.xxx.xxx:xxxx' | |
def push(): | |
try: | |
req = urllib2.Request(API_URL) | |
if not req.has_proxy(): | |
req.set_proxy(PROXY, 'https') | |
data = {'apikey': API_KEY, | |
'application': 'xxxxx', | |
'event': 'xxxx', | |
'description': 'xxxxx', | |
'priority': 0} | |
req.add_data(urllib.urlencode(data)) | |
urllib2.urlopen(req) | |
except Exception: | |
print('-') | |
pass | |
push() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment