-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWeb Scraping - house-mixes.com.applescript
More file actions
91 lines (66 loc) · 5.58 KB
/
Web Scraping - house-mixes.com.applescript
File metadata and controls
91 lines (66 loc) · 5.58 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
-- This Script will download all the MP3s from a specifix user from house-mixes.com
tell application "Safari"
activate
make new document
set downloadCount to 0
tell document 1
set URL to "https://www.house-mixes.com/profile/bartoszt/mediabywidget/1/latest"
delay 120
#get number of pages
repeat with i from 0 to do JavaScript "document.getElementsByClassName('pagination pagination-centered')[0].childElementCount"
if (do JavaScript "document.getElementsByClassName('pagination pagination-centered')[0].childNodes[" & i & "].textContent") contains "→" then
set pageCount to do JavaScript "document.getElementsByClassName('pagination pagination-centered')[0].childNodes[7].previousElementSibling.textContent"
end if
end repeat
repeat with i from 1 to pageCount # Loop through the pages
# get number of songs on this page
set numberOfSongsOnThisPage to do JavaScript "document.getElementsByClassName('audio-image-link').length"
repeat with j from 0 to numberOfSongsOnThisPage - 1
try
set songName to words of (do JavaScript "document.getElementsByClassName('audio-image-link')[" & j & "].innerHTML")
end try
try
do JavaScript "document.getElementsByClassName('audio-image-link')[" & j & "].click()" # click on song art
end try
delay 3
try
do JavaScript "document.getElementsByClassName('btn btn-orange button-download')[0].click()" # first download button
end try
delay 3
try
do JavaScript "document.getElementsByClassName('btn btn-primary')[1].click()" # second download button
end try
delay 3
try
do JavaScript "document.getElementById('btnDownload').click()" # third and final download button
delay 3
end try
set downloadCount to downloadCount + 1
repeat with k from 1 to count of songName
if item k of songName is "alt" then
set startRead to k
exit repeat
end if
end repeat
tell me to say "Clicked to download"
repeat with k from startRead + 2 to (count of songName) - 1
tell me to say item (k) of songName
end repeat
tell me to say "which is page" & i & "song" & (j + 1)
tell me to say "which is song number " & downloadCount
do JavaScript "history.back()"
delay 3
tell application "System Events" to key code 125 using command down
end repeat
if i is less than pageCount then
tell me to say "Going to the next page, which is page" & i + 1
end if
if i is less than pageCount then
set the URL to "https://www.house-mixes.com/profile/bartoszt/mediabywidget/1/latest" & "/" & i + 1
end if
delay 5
tell application "System Events" to key code 125 using command down
delay 5
end repeat
end tell
end tell