-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWeb Scraping - Coursera - Pull Degree Info.applescript
More file actions
38 lines (35 loc) · 1.59 KB
/
Web Scraping - Coursera - Pull Degree Info.applescript
File metadata and controls
38 lines (35 loc) · 1.59 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
-- This script scrapes all the business degrees from a specific Coursera web page
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application "Safari"
activate
tell document 1
set URL to "https://www.coursera.org/degrees/business#mastersdegreelist"
delay 5
set numOfSchools to do JavaScript "document.getElementsByClassName('font-md font-weight-bold d-block').length"
set university to {}
repeat with i from 0 to numOfSchools - 1
set degreeType to do JavaScript "document.getElementsByClassName('font-md font-weight-bold d-block')[" & i & "].textContent"
set universityName to do JavaScript "document.getElementsByClassName('font-sm m-b-0 d-block')[" & i & "].textContent"
set duration to do JavaScript "document.getElementsByClassName('program-details font-weight-bold m-t-1s m-b-0')[" & i & "].textContent"
set ranking to do JavaScript "document.getElementsByClassName('ranking-description font-sm d-block m-t-1s')[" & i & "].textContent"
set end of university to {degreeType, universityName, duration, ranking}
end repeat
end tell
end tell
tell application "Numbers"
activate
make new document
tell document 1
tell sheet 1
tell table 1
repeat with i from 1 to count of university
set value of cell (i + 1) of column 1 to item 1 of item i of university
set value of cell (i + 1) of column 2 to item 2 of item i of university
set value of cell (i + 1) of column 3 to item 3 of item i of university
set value of cell (i + 1) of column 4 to item 4 of item i of university
end repeat
end tell
end tell
end tell
end tell