Skip to content

Instantly share code, notes, and snippets.

@matchai
Created June 13, 2018 19:26
Show Gist options
  • Save matchai/aa4d80ed1b60001847d156373e46f02b to your computer and use it in GitHub Desktop.
Save matchai/aa4d80ed1b60001847d156373e46f02b to your computer and use it in GitHub Desktop.
#!/usr/local/bin/python3
# <bitbar.title>Cotton Bureau Sales</bitbar.title>
# <bitbar.version>v2.0</bitbar.version>
# <bitbar.author>Matan Kushner</bitbar.author>
# <bitbar.author.github>matchai</bitbar.author.github>
# <bitbar.desc>Checks Cotton Bureau page for the number of sales</bitbar.desc>
# <bitbar.dependencies>python</bitbar.dependencies>
# <bitbar.emojize>true</bitbar.emojize>
import urllib.request, json, time
with urllib.request.urlopen("https://cottonbureau.com/products/anilist") as url:
data = url.read().decode()
start = "\"sold\":"
end = ","
firstChar = data.find(start)
lastChar = data.find(end, firstChar)
number_of_sales = data[firstChar + len(start):lastChar]
print(":shirt:: " + number_of_sales)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment