Added check for no likes or reposts on tracks
This commit is contained in:
parent
717d7ae6c0
commit
3c160b71c1
12
scrape.py
12
scrape.py
@ -219,12 +219,20 @@ def Get_Tracks_Info(url, limit = 100):
|
||||
# Grab the like count
|
||||
like_elem = track_elem.find(class_='sc-button-like')
|
||||
if like_elem:
|
||||
track.likes = Human_Str_To_Int(str(like_elem.string.strip()))
|
||||
like_elem_text = str(like_elem.string.strip())
|
||||
if 'like' in like_elem_text.lower():
|
||||
track.likes = 0
|
||||
else:
|
||||
track.likes = Human_Str_To_Int(like_elem_text)
|
||||
|
||||
# Grab the repost count
|
||||
repost_elem = track_elem.find(class_='sc-button-repost')
|
||||
if repost_elem:
|
||||
track.reposts = Human_Str_To_Int(str(repost_elem.string.strip()))
|
||||
repost_elem_text = str(repost_elem.string.strip())
|
||||
if 'repost' in repost_elem_text.lower():
|
||||
track.reposts = 0
|
||||
else:
|
||||
track.reposts = Human_Str_To_Int(repost_elem_text)
|
||||
|
||||
# Finally add the track to the dictionary
|
||||
tracks[track.url] = track
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user