Get username, track count, and like count
This commit is contained in:
parent
7c7c016e27
commit
7cb2e2a2ff
24
scrape.py
24
scrape.py
@ -35,5 +35,25 @@ print('WebDriver initialised')
|
||||
|
||||
##### Do stuff ##############################################
|
||||
|
||||
username = soup.find(class_='profileHeaderInfo__userName')
|
||||
print(username.string.strip())
|
||||
user_dict = {}
|
||||
users_to_process = ['thomotron', 'lacheque', 'slynk']
|
||||
|
||||
for user in users:
|
||||
# Skip any users that have already been passed over to avoid infinite loops
|
||||
if user in user_dict.keys():
|
||||
continue
|
||||
|
||||
driver.get('https://soundcloud.com/' + user)
|
||||
soup = BeautifulSoup(driver.page_source, 'lxml')
|
||||
|
||||
# Use stripped_strings generator as workaround for users with premium badge
|
||||
username = next(soup.find(class_='profileHeaderInfo__userName').stripped_strings)
|
||||
print(username)
|
||||
|
||||
track_count = int(soup.find('a', href='/' + username.lower() + '/tracks', class_='infoStats__statLink').div.string)
|
||||
print(track_count)
|
||||
|
||||
like_count = int(soup.find('a', href='/' + username.lower() + '/likes').find(class_='sidebarHeader__actualTitle').string.split(' ')[0])
|
||||
print(like_count)
|
||||
|
||||
driver.quit()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user