Skip to content

Instantly share code, notes, and snippets.

@xavdid xavdid/
Last active Aug 29, 2015

What would you like to do?
Grabs an appshopper feed url and returns the most recent discount
# Given an appshopper url, find the most recent price drop
# author: David Brownman
# www:
# NOTE: the clipboard module is unique to pythonista.
import clipboard
import feedparser
import re
import webbrowser
# takes "$4.99" and returns $5
def round(p):
price = p.split(".")
print price
dollar = int(price[0][1:]) if price[0] != '$' else 0
cents = int(price[1])
if cents > 75:
dollar += 1
return "$%s" % dollar
return p
def main():
url = clipboard.get()
# url = ""
feed = feedparser.parse(url)
for i in feed.entries:
# we're only intrested in price drops
if i.title.split()[1] == "Drop:":
app =": *(.*)\(", i.title).group(1).strip()
p ="Price:\<\/b> ?([$.\d\-\> ]*),", i.description).group(1).split(" -> ")
# this should always find a result, but it never hurts to be careful
prices = [round(p) for p in p]
result = "%s|%s|%s" % (app, prices[0], prices[1])
# print result
# workflow phone home"workflow://")
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.