diff --git a/scrape.py b/scrape.py index 2194772..045aad6 100755 --- a/scrape.py +++ b/scrape.py @@ -145,7 +145,7 @@ def Get_Tracks_Info(url, limit = 100): track.artist = artist_elem.string.strip() # Check if we have already gotten this track before - if track.artist + track.title in tracks.keys(): + if str(track.artist) + str(track.title) in tracks.keys(): continue # Grab when it was uploaded @@ -169,10 +169,14 @@ def Get_Tracks_Info(url, limit = 100): track.comments = num # Grab the like count - track.likes = track_elem.find(class_='sc-button-like').string.strip() + like_elem = track_elem.find(class_='sc-button-like') + if like_elem: + track.likes = like_elem.string.strip() # Grab the repost count - track.reposts = track_elem.find(class_='sc-button-repost').string.strip() + repost_elem = track_elem.find(class_='sc-button-repost') + if repost_elem: + track.reposts = repost_elem.string.strip() # Finally add the track to the dictionary tracks[track.artist + track.title] = track