Genericise Get_Tracks_Info to take any infiniscrolling list URL
This commit is contained in:
parent
33dd9edcdc
commit
8b4c3f5489
12
scrape.py
12
scrape.py
@ -96,10 +96,10 @@ def Get_Basic_Info(user):
|
||||
user.like_count = like_count_elem.string.split(' ')[0]
|
||||
print(' Likes: ' + str(user.like_count))
|
||||
|
||||
def Get_Tracks_Info(user):
|
||||
# Get the user's tracks page and soup it
|
||||
print('GET: https://soundcloud.com/' + user.url_username + '/tracks')
|
||||
driver.get('https://soundcloud.com/' + user.url_username + '/tracks')
|
||||
def Get_Tracks_Info(url):
|
||||
# Get the page and soup it
|
||||
print('GET: ' + url)
|
||||
driver.get(url)
|
||||
|
||||
# Loop until we reach the bottom of the page so all tracks are loaded
|
||||
while True:
|
||||
@ -170,7 +170,7 @@ def Get_Tracks_Info(user):
|
||||
|
||||
print(' ' + track.artist + ' - ' + track.title)
|
||||
|
||||
user.tracks = tracks
|
||||
return tracks
|
||||
|
||||
user_dict = {}
|
||||
users_to_process = ['thomotron', 'lacheque', 'slynk', 'bossfightswe']
|
||||
@ -192,7 +192,7 @@ for user_str in users_to_process:
|
||||
Get_Basic_Info(user)
|
||||
|
||||
# Get their tracks
|
||||
Get_Tracks_Info(user)
|
||||
user.tracks = Get_Tracks_Info('https://soundcloud.com/' + user.url_username + '/tracks')
|
||||
|
||||
# Finally add the user to the dictionary
|
||||
user_dict[user.url_username] = user
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user