From 1c9216ac1d16a07c79212d2b1c3e426f73d67cb2 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Thu, 13 Feb 2014 11:57:10 +1300 Subject: [PATCH] commented! --- plugins/steam.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/steam.py b/plugins/steam.py index 289d6ca..f5fc7e0 100644 --- a/plugins/steam.py +++ b/plugins/steam.py @@ -19,26 +19,37 @@ def get_steam_info(url): # get the element details_block details = soup.find('div', {'class': 'details_block'}) - # MAGIC + # loop over every tag in details_block for b in details.findAll('b'): + # get the contents of the tag, which is our title title = b.text.lower().replace(":", "") if title == "languages": # we have all we need! break + # find the next element directly after the tag next = b.nextSibling if next: + # if the element is some text if isinstance(next, NavigableString): text = next.string.strip() if text: + # we found valid text, save it and continue the loop data[title] = text continue - else: + else: + # the text is blank - sometimes this means there are + # useless spaces or tabs between the and tags. + # so we find the next tag and carry on to the next + # bit of code below next = next.find_next('a', href=True) + # if the element is an tag if isinstance(next, Tag) and next.name == 'a': text = next.string.strip() if text: + # we found valid text (in the tag), + # save it and continue the loop data[title] = text continue