Created
June 13, 2018 19:26
-
-
Save matchai/aa4d80ed1b60001847d156373e46f02b to your computer and use it in GitHub Desktop.
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
#!/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