diff --git a/scrape.py b/scrape.py index 32a5ef3..f2853b8 100755 --- a/scrape.py +++ b/scrape.py @@ -108,24 +108,27 @@ def Get_Basic_Info(user): print(' Username: ' + user.username) # Grab their track count - track_count = soup.find('a', href='/' + user.url_username + '/tracks', class_='infoStats__statLink').div.string - user.track_count = track_count - print(' Tracks: ' + user.track_count) + track_count_elem = soup.find('a', href='/' + user.url_username + '/tracks', class_='infoStats__statLink') + if track_count_elem: + user.track_count = str(track_count_elem.div.string) + print(' Tracks: ' + str(user.track_count)) # Grab their following count - following_count = soup.find('a', href='/' + user.url_username + '/following', class_='infoStats__statLink').div.string - user.following_count = following_count + following_count_elem = soup.find('a', href='/' + user.url_username + '/following', class_='infoStats__statLink') + if following_count_elem: + user.following_count = str(following_count_elem.div.string) print(' Following: ' + str(user.following_count)) # Grab their follower count - follower_count = soup.find('a', href='/' + user.url_username + '/followers', class_='infoStats__statLink').div.string - user.follower_count = follower_count + follower_count_elem = soup.find('a', href='/' + user.url_username + '/followers', class_='infoStats__statLink') + if follower_count_elem: + user.follower_count = str(follower_count_elem.div.string) print(' Followers: ' + str(user.follower_count)) # Grab their like count like_count_elem = soup.find('a', href='/' + user.url_username + '/likes', class_='sidebarHeader__actualTitle') if like_count_elem: - user.like_count = like_count_elem.string.split(' ')[0] + user.like_count = str(like_count_elem.string.split(' ')[0]) print(' Likes: ' + str(user.like_count)) # Gets a list of fully-populated Track objects