Sprinkle a bit of NoneType safety into the mix
This commit is contained in:
parent
cde49030dc
commit
cdf78f0208
10
scrape.py
10
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user