From 8b4c3f54893ed2291f90dca67dd630e8fd839412 Mon Sep 17 00:00:00 2001 From: Thomas Wade Date: Wed, 19 Sep 2018 20:48:21 +0930 Subject: [PATCH] Genericise Get_Tracks_Info to take any infiniscrolling list URL --- scrape.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scrape.py b/scrape.py index 15e05ee..49d4fbf 100755 --- a/scrape.py +++ b/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