-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02-check-downloads.r
45 lines (33 loc) · 1.27 KB
/
02-check-downloads.r
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
library(tidyverse)
library(rvest)
# [NOTE] checks required to ensure all abstracts (`abstract_id`) are assigned
# to a session (`session_id`); if not, some abstracts end up being
# 'orphaned' with `NA` as their `session_id`
# check sessions ----------------------------------------------------------
# get all sessions listed in authors listings
f <- fs::dir_ls("html/authors/") %>%
map(read_html) %>%
map(html_nodes, xpath = "//a[contains(@href, 'session')]") %>%
map(html_attr, "href") %>%
unlist() %>%
unique() %>%
str_replace(".*?/(\\d{4})$", "html/sessions/session_\\1.html")
# sanity check: found a result in every URL
stopifnot(!is.na(f))
# sanity check: all have downloaded
stopifnot(fs::file_exists(f))
# check abstracts ---------------------------------------------------------
# get all abstracts listed in authors listings
f <- fs::dir_ls("html/authors/") %>%
map(read_html) %>%
map(html_nodes, xpath = "//a[contains(@href, 'submission')]") %>%
map(html_attr, "href") %>%
unlist() %>%
unique() %>%
str_replace(".*?/(\\d{5,6})$", "html/abstracts/abstract_\\1.html")
# sanity check: found a result in every URL
stopifnot(!is.na(f))
# sanity check: all have downloaded
stopifnot(fs::file_exists(f))
cat("All downloads completed.\n")
# kthxbye