-
Notifications
You must be signed in to change notification settings - Fork 0
/
mxdl.py
49 lines (33 loc) · 1.2 KB
/
mxdl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import selenium
import time
from selenium import webdriver
chromedriver_path = "/usr/lib/chromium-browser/chromedriver"
driver = webdriver.Chrome(executable_path=chromedriver_path)
###change this
playlisturl = "https://www.mixcloud.com/lowlight/"
driver.get(playlisturl)
SCROLL_PAUSE_TIME = 2
# Get scroll height
last_height = driver.execute_script("return document.body.scrollHeight")
while True:
# Scroll down to bottom
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
# Wait to load page
time.sleep(SCROLL_PAUSE_TIME)
# Calculate new scroll height and compare with last scroll height
new_height = driver.execute_script("return document.body.scrollHeight")
if new_height == last_height:
break
last_height = new_height
linklist = driver.find_elements_by_css_selector(".card-title h1 a")
#transform to downloader links
newlinks = []
for link in linklist:
href = link.get_attribute("href")
newlink = href.replace("https://www.mixcloud.com/", "http://www.mixcloud-downloader.com/dl/mixcloud/")
newlinks.append(newlink)
#download all the linkes in the linklst
for newlink in newlinks:
driver.get(newlink)
time.sleep(3)
driver.close()