diff --git a/pcslive.py b/pcslive.py index 3dc5fdf..f36ae73 100644 --- a/pcslive.py +++ b/pcslive.py @@ -4,6 +4,7 @@ import requests, time # class for storing the live races class LiveStats: def __init__(self): + self.races = [] self.refresh_races() # scrapes from the PCS homepage where the little green live stats boxes are @@ -18,21 +19,23 @@ class LiveStats: # races are currently live live = soup.find(attrs={"class":"hp3-livestats"}) - # also get rid of the horrible polygon number stuff !!! YUCK - # i imagine its how the profiles are drawn. there is A LOT - # and it makes reading the raw html very PAINFUL - for tag in live.find_all(attrs={"class":"inverse"}): - tag.decompose() + # if there are even any races: + if live: + # also get rid of the horrible polygon number stuff !!! YUCK + # i imagine its how the profiles are drawn. there is A LOT + # and it makes reading the raw html very PAINFUL + for tag in live.find_all(attrs={"class":"inverse"}): + tag.decompose() - # conveniently, every race is a list item (