Add some comments

This commit is contained in:
Thomas Wade 2018-09-29 15:01:42 +09:30
parent 3c160b71c1
commit 3a2f5d1932

View File

@ -172,6 +172,7 @@ def Get_Tracks_Info(url, limit = 100):
tracks = {} tracks = {}
# Get all of the track elements up to the given limit
track_elems = soup.find_all('li', class_='soundList__item')[:limit] track_elems = soup.find_all('li', class_='soundList__item')[:limit]
for track_elem in track_elems: for track_elem in track_elems:
# Initialise a track object to hold our data # Initialise a track object to hold our data
@ -272,8 +273,10 @@ def Get_Follows(url, limit = 100):
users = {} users = {}
# Get all of the user badges up to the given limit
badge_elems = soup.find_all(class_='badgeList__item')[:limit] badge_elems = soup.find_all(class_='badgeList__item')[:limit]
for badge_elem in badge_elems: for badge_elem in badge_elems:
# Grab their URL username
username_elem = badge_elem.find('a', class_='userBadgeListItem__heading') username_elem = badge_elem.find('a', class_='userBadgeListItem__heading')
if username_elem: if username_elem:
user = User() user = User()
@ -282,8 +285,10 @@ def Get_Follows(url, limit = 100):
print(' ' + user.url_username) print(' ' + user.url_username)
# Return just the values to make adding to the list easier
return users.values() return users.values()
# Converts string representations of numbers such as '1,234' or '35.6M' to integers
def Human_Str_To_Int(string): def Human_Str_To_Int(string):
num = None num = None
string = string.lower().replace(',', '') string = string.lower().replace(',', '')