Skip to content

Instantly share code, notes, and snippets.

@jjasghar
Forked from donniebishop/pokestat.py
Created July 18, 2016 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjasghar/fb81388f143e20a1fdcc761f1d6c60d5 to your computer and use it in GitHub Desktop.
Save jjasghar/fb81388f143e20a1fdcc761f1d6c60d5 to your computer and use it in GitHub Desktop.
i3-blocklet for checking Pokemon Go status
#!/usr/bin/env python3
from bs4 import BeautifulSoup
import requests
POKEURL = 'http://cmmcd.com/PokemonGo/'
STATUSES = {
'Online!': 0,
'Unstable!': 1,
'Offline!': 2,
}
r = requests.get(POKEURL)
try:
import lxml
soup = BeautifulSoup(r.text, 'lxml')
except ImportError:
soup = BeautifulSoup(r.text, 'html.parser')
status = STATUSES[soup.body.header.h2.font.text]
if __name__ == '__main__':
if status == 1:
u = ' PKGO Shaky!'
print(u)
elif status == 2:
d = ' PKGO Down!'
print(d)
else:
exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment