generated from 360-info/quarto-scaffold
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.qmd
697 lines (598 loc) · 23.6 KB
/
index.qmd
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
---
title: "Platforms and Power"
subtitle: "Visualising the changing length of user agreements"
author: "James Goldie, 360info"
date: "2022-05-12"
code-fold: true
theme: style/article.scss
---
This demo analyses the changing length of the user agreements that major tech companies use. We'll use the [Wayback Machine API](https://archive.org/help/wayback_api.php) to identify snapshots of platform APIs, extract the text at different points in time, and analyse their word length.
```{r}
library(tidyverse)
library(urltools)
library(httr)
library(rvest)
library(stringr)
library(tidytext)
library(lubridate)
library(collateral)
library(themes360info)
library(ggtext)
library(here)
```
## Introduction
The Wayback Machine has thousands of scrapes of [Facebook's Terms of Service](https://www.facebook.com/terms.php) over the last 15 years, and I don't think we can look at all of them. But we could probably look at, say, one each month.
One thing I've noticed is that Facebook's Terms link out to a bunch of other policies and agreements, governing various feratures. Some of them, like Developer Payment Policies, may only affect a small subset of users - but others, like Groups, Pages and Events, would cover most regular Facebook users!
One approach to handling these ancillary agreements is to modify our scraper to pull out links from the primary agreement and to scrape those for the same date too.
We need to be careful to screen out duplicate links too, though, and if those terms in turn link to others, we'd need to screen out ones we'd already scraped to avoid circular definitions. For now, let's just recurse one level, rather than trying to map out an entire tree of agreements.
Let's start with the snapshot request function:
```{r}
#| label: reqsnapshotfn
#| code-fold: true
#| code-summary: "Show the snapshot request function"
#' @param url The url of the page to look up (eg.
#' https://www.facebook.com/terms.php)
#' @param dt A Date object, or a string in YYMMDD format, to try and get the
#' snapshot from. If ommitted, the latest is used.
#' @return A list containing:
#' - dt: the actual date-time of the snapshot
#' - snapshot_url: the url of the snapshot
request_snapshot <- function(url, dt) {
# construct the url to lookup the snapshot (add timestamp if requested)
lookup_url <- paste0("http://archive.org/wayback/available?url=", url)
if (!is_empty(dt)) {
if (class(dt) == "Date") {
lookup_url <- paste0(lookup_url, "×tamp=", format(dt, "%Y%M%d"))
} else {
lookup_url <- paste0(lookup_url, "×tamp=", dt)
}
}
response <- GET(lookup_url)
# check for missing content
if (response$status != 200L) {
warning(paste("HTTP", response$status, "thrown"))
}
# print(content(response))
is_available <- content(response)$archived_snapshots$closest$available
if (is_empty(is_available) || (!is_available)) {
stop("No snapshot available")
}
# extract the actual snapshot time and url
snapshot_url <- content(response)$archived_snapshots$closest$url
snapshot_dt <-
content(response)$archived_snapshots$closest$timestamp %>%
ymd_hms()
return(list(
snapshot_dt = snapshot_dt,
snapshot_url = snapshot_url))
}
```
And now the scraping function. One challenge here is that Facebook's policy pages have adopted many designs over the years (and even at the same time for different policies), and so the CSS selector required varies. I've adopted a fallback approach, where the function takes a _vector_ of potential CSS selectors. It tries them in succession until it finds one in the document and then uses that to extract the text:
```{r}
#| label: getwordslinksfn
#| code-fold: true
#| code-summary: "Show the words and links scraping function"
#' @param url The url of the page snapshot to look up (eg.
#' https://web.archive.org/web/20220223013629/
#' https://www.facebook.com/terms.php)
#' @param css A vector of CSS selectors from which to attempt to extract article
#' text. These are tried successively until one is found in the page.
#' @return A list containing:
#' - dt: the actual date-time of the snapshot
#' - url: the url of the snapshot
#' - words: a tidy data frame of word tokens by paragraph, as returned by
#' tidytext::unnest_tokens
get_words_and_links <- function(snapshot_url, css) {
if (is_empty(snapshot_url) | is.na(snapshot_url)) {
stop("Snapshot URL is missing")
}
# extract the snapshot content
scrape <- read_html(snapshot_url)
# first, let's try to detect the selector that has the page content in it. this
# varies by page and over time!
# css_tries <- c("section._9lea", "#rebrandBodyID", "#content")
for (css_try in css) {
scrape_content <- scrape %>% html_elements(css_try)
if (length(scrape_content) > 0L) {
break;
}
}
if (length(scrape_content) == 0L) {
stop("Couldn't auto-detect article content using supplied CSS")
}
# identify links
scrape_content %>%
html_elements("a") %>%
{ tibble(url = html_attr(., "href"), label = html_text(.)) } %>%
# <a> based on label
filter(str_detect(label,
regex("terms|policy|policies|notice|procedure|guideline|tips|here",
ignore_case = TRUE))) %>%
filter(str_detect(label, coll("printable", ignore_case = TRUE),
negate = TRUE)) %>%
filter(str_detect(label, coll("plain text", ignore_case = TRUE),
negate = TRUE)) %>%
filter(str_detect(label, coll("contact", ignore_case = TRUE),
negate = TRUE)) %>%
filter(str_detect(label, coll("support", ignore_case = TRUE),
negate = TRUE)) ->
scrape_links_untidy
# remove the fragments and parameters from the urls
# (so that we can detect and remove internal links, like tables of contents)
fragment(scrape_links_untidy$url) <- NULL
parameters(scrape_links_untidy$url) <- NULL
# we need to fix relative links by getting the snapshot url folder and
# prepending it. let's pull that out first
snapshot_url_site <-
url_parse(snapshot_url) %>%
# mutate(path = str_replace(path, "[^/]+$", "")) %>%
mutate(path = "") %>%
url_compose()
scrape_links_untidy %>%
# fix relative links...
mutate(url = if_else(
is.na(scheme(url)),
paste0(snapshot_url_site, url),
url)) %>%
# ... and reuplicate and internal ones
distinct(url, .keep_all = TRUE) %>%
filter(url != snapshot_url) %>%
# tinally, tidy up labels. if they have "here" in them, replace with the
# filename (sans extension)
mutate(
label = str_trim(label),
label = if_else(
str_detect(label, "here"),
tools::file_path_sans_ext(basename(url)),
label)) ->
scrape_links
# extract the text from the page and break it by paragraph
# (content with multiple selectors is concatenated into pars first!)
scrape_content %>%
html_text2() %>%
paste(collapse = "\n\n") %>%
str_split(regex("\n+")) %>%
pluck(1) ->
scrape_text
# finally, unnest the words of the agreement
scrape_text %>%
tibble(para = 1:length(.), text = .) %>%
unnest_tokens(word, text) ->
scrape_words
# return the words and the
return(list(
words = scrape_words,
links = scrape_links
))
}
```
A quick function to save our processed word counts:
```{r}
#| label: savetermsfn
#| code-fold: true
#| code-summary: "Show the term saving function"
save_terms <- function(terms, date, policy, platform) {
dir.create(here("data", "terms", platform, date), recursive = TRUE)
policy_safe <- str_to_lower(str_replace_all(policy, " ", "-"))
write_csv(terms, here("data", "terms", platform, date,
paste0(policy_safe, ".csv")))
}
```
Now, finally, let's encapsulate the higher level tidying:
```{r}
#| label: analysisfn
analyse_platform <- function(platform, primary_url, date_seq, css_tries,
scrape_links = TRUE, test = FALSE, primary_name = "Terms of Use") {
message("Beginning analysis...")
# assemble the combos of link requests over time
primary_terms <- tibble(url = primary_url, type = "primary")
dt <- date_seq
primary_term_history <- expand_grid(primary_terms, dt)
# if testing, just take the first and last 2 dates for each url
if (test) {
message("TEST MODE ON")
primary_term_history <-
primary_term_history %>%
group_by(url) %>%
slice(c(1:2, (n() - 1):n())) %>%
ungroup()
}
# --- first round: scrape the primary terms of use --------------------------
message("Scraping primary terms of use...")
primary_term_history %>%
mutate(
# do the intiial lookup
lookup = map2_peacefully(url, dt, request_snapshot),
prim_snapshot_dt = map(lookup, c("result", "snapshot_dt")),
prim_snapshot_url = map_chr(lookup, c("result", "snapshot_url"),
.default = NA),
# then scrape the snapshot
prim_scrape = map_peacefully(prim_snapshot_url, get_words_and_links,
css = css_tries),
prim_words = map(prim_scrape, c("result", "words")),
prim_links = map(prim_scrape, c("result", "links"))) %>%
unnest(prim_snapshot_dt) %>%
mutate(
label = primary_name,
word_count = map_int(prim_words,
~ ifelse(!is_empty(.x), nrow(.x), NA_integer_))) ->
terms_firststage
message("Checking for scraping errors in primary terms...")
terms_firststage %>%
filter(has_errors(prim_scrape)) %>%
mutate(err = map_chr(prim_scrape, c("error", "message"), .default = NA)) %>%
select(dt, prim_scrape, err) %>%
print()
message("Writing primary terms of use to disk...")
# write the processed terms out to csvs
terms_firststage %>%
filter(!has_errors(prim_scrape)) %>%
select(terms = prim_words, date = dt, policy = label) %>%
pmap_peacefully(save_terms, platform = platform)
if (scrape_links) {
# --- second round: scrape the discovered links ---------------------------
message("Scraping discovered links...")
terms_firststage %>%
select(dt, prim_links) %>%
unnest_longer(prim_links) %>%
unpack(prim_links) %>%
# discard NAs and duplicate policies
distinct(dt, url, .keep_all = TRUE) %>%
drop_na(url) %>%
mutate(
# recover the original link from the wayback-substituted one
original_url = str_replace(
str_replace(url, fixed("http://web.archive.org"), ""),
regex("/web/[:digit:]{14}/"), ""),
# do the initial lookup
lookup = map2_peacefully(original_url, dt, request_snapshot),
sec_snapshot_dt = map(lookup, c("result", "snapshot_dt"), .null = NA),
sec_snapshot_url = map_chr(lookup, c("result", "snapshot_url"), .null = NA),
sec_scrape = map_peacefully(sec_snapshot_url, get_words_and_links,
css = css_tries),
sec_words = map(sec_scrape, c("result", "words"))) %>%
unnest(sec_snapshot_dt) %>%
mutate(
type = "secondary",
word_count = map_int(sec_words,
~ ifelse(!is_empty(.x), nrow(.x), NA_integer_))) ->
terms_secondary
message("Checking for scraping errors in primary terms...")
terms_secondary %>%
filter(has_errors(sec_scrape)) %>%
mutate(err = map_chr(sec_scrape, c("error", "message"), .default = NA)) %>%
select(dt, label, sec_scrape, err) %>%
print()
message("Writing secondary agreements to disk...")
# write the processed terms out to csvs
terms_secondary %>%
filter(!has_errors(sec_scrape)) %>%
select(terms = sec_words, date = dt, policy = label) %>%
pmap_peacefully(save_terms, platform = platform)
message("Merging primary and secondary agreement word counts...")
terms_all <-
bind_rows(
terms_firststage %>%
select(type, label, url, dt, scrape = prim_scrape,
snapshot_dt = prim_snapshot_dt, snapshot_url = prim_snapshot_url,
word_count),
terms_secondary %>%
select(type, label, url = original_url, dt, scrape = sec_scrape,
snapshot_dt = sec_snapshot_dt, snapshot_url = sec_snapshot_url,
word_count)) %>%
rename(policy_name = label, target_url = url , target_dt = dt)
} else {
terms_all <-
terms_firststage %>%
select(type, label, url, dt, scrape = prim_scrape,
snapshot_dt = prim_snapshot_dt, snapshot_url = prim_snapshot_url,
word_count)
}
message("Done!")
return(terms_all)
}
```
Now that we have our essential machinery, we can run this scraper - first on Facebook's primary terms of use over time, then on the extracted links!
## Facebook
```{r}
#| label: setupfb
fb_css <- c("section._9lea", "#rebrandBodyID", "#content", "#PolicyPageContent",
"#u_0_2_hz", "#u_0_9_uG",
".documentation .content", "body table.bordertable[border=\"1\"]",
"div[role=\"main\"]")
analyse_facebook <- partial(analyse_platform,
platform = "facebook",
date_seq = seq(as.Date("2005-12-15"), Sys.Date(), by = "month"),
css_tries = fb_css)
```
```{r}
#| label: scrapefb
fb_words <- analyse_facebook(primary_url = "https://www.facebook.com/terms.php")
fb_words %>%
select(-scrape) %>%
filter(word_count > 250) %>%
filter(str_detect(snapshot_url, coll("german"), negate = TRUE)) %>%
filter(str_detect(snapshot_url, coll("help.php?page=926"), negate = TRUE)) %>%
group_by(target_dt) %>%
distinct(snapshot_url, .keep_all = TRUE) ->
fb_words_tidy
fb_words_tidy %>%
write_csv(here("data", "terms", "facebook.csv"))
```
Let's see what the word counts have looked like over time:
```{r}
#| label: visfb
fb_words_tidy %>%
group_by(type, target_dt) %>%
summarise(word_count = sum(word_count, na.rm = TRUE)) %>%
ungroup() %>%
mutate(type =
if_else(type == "primary", "Primary terms", "Secondary agreements")) %>%
{
ggplot(.) +
aes(x = target_dt, y = word_count) +
geom_area(aes(fill = type) , position = position_stack(reverse = TRUE)) +
# geom_point(aes(colour = type)) +
# scale_fill_brewer(type = "qual") +
scale_fill_manual(
values = c(
"Primary terms" = "#4267b2",
"Secondary agreements" = "#93d1f5"),
guide = NULL) +
scale_y_continuous(
labels = scales::label_number(scale = 1/1000, suffix = "k words")) +
annotate_360_glasslight(
x = as.Date("2018-01-01"), y = 1500, size = 4,
label = "<span style=\"color:white;\">**PRIMARY TERMS**</span>"
) +
annotate_360_glasslight(
x = as.Date("2018-01-01"), y = 8000, size = 4,
label = "<span style=\"color:#4267b2;\">**SECONDARY AGREEMENTS**</span>"
) +
theme_360() +
theme(
legend.position = c(0.5, 0.85),
legend.direction = "horizontal",
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.subtitle = element_markdown(family = "Body 360info", face = "plain")
) +
labs(x = NULL, y = NULL, fill = NULL,
title = toupper("Facebook's growing fine print"),
subtitle = paste(
"In 2005, Facebook's terms of service comprised **two policies totalling under 3 000 words**.",
"Since then, they've **grown tenfold** into a behomoth comprising **at least nine policies.***",
sep = "<br>"),
caption = paste(
"**CHART:** James Goldie, 360info",
"* This is a likely underestimate: secondary agreements in turn link to",
"tertiary ones that we were unable to assess.", sep = "<br>"))
} %>%
save_360plot(here("out", "wordcounts-facebook.png"), shape = "sdtv-landscape") %>%
save_360plot(here("out", "wordcounts-facebook.svg"), shape = "sdtv-landscape")
```
## Tinder
https://policies.tinder.com/terms/intl/en
```{r}
#| label: setuptinder
tinder_css <- c("main", "body")
analyse_tinder <- partial(analyse_platform,
platform = "tinder",
css_tries = tinder_css)
```
```{r}
#| label: scrapetinder
tinder_words_old <- analyse_tinder(
primary_url = "https://gotinder.com/terms",
date_seq = seq(as.Date("2013-03-01"), as.Date("2020-07-01"), by = "month"))
tinder_words_new <- analyse_tinder(
primary_url = "https://policies.tinder.com/terms/intl/en",
date_seq = seq(as.Date("2017-08-01"), Sys.Date(), by = "month"))
tinder_words_all <-
bind_rows(tinder_words_old, tinder_words_new) %>%
filter(!has_errors(scrape)) %>%
group_by(target_dt) %>%
distinct(snapshot_url, .keep_all = TRUE) %>%
ungroup() ->
tinder_words_tidy
tinder_words_tidy %>%
select(-scrape) %>%
write_csv(here("data", "terms", "tinder.csv"))
```
Let's see what the word counts have looked like over time:
```{r}
#| label: visfb
tinder_words_tidy %>%
group_by(type, target_dt) %>%
summarise(word_count = sum(word_count, na.rm = TRUE)) %>%
ungroup() %>%
mutate(type =
if_else(type == "primary", "Primary terms", "Secondary agreements")) %>%
{
ggplot(.) +
aes(x = target_dt, y = word_count) +
geom_area(aes(fill = type) , position = position_stack(reverse = TRUE)) +
# geom_point(aes(colour = type)) +
# scale_fill_brewer(type = "qual") +
scale_fill_manual(
values = c(
"Primary terms" = "#eb487c",
"Secondary agreements" = "#ef7b5b"),
guide = NULL) +
scale_y_continuous(
labels = scales::label_number(scale = 1/1000, suffix = "k words")) +
annotate_360_glasslight(
x = as.Date("2018-01-01"), y = 1500, size = 4,
label = "<span style=\"color:white;\">**PRIMARY TERMS**</span>"
) +
annotate_360_glasslight(
x = as.Date("2018-01-01"), y = 8000, size = 4,
label = "<span style=\"color:#eb487c;\">**SECONDARY AGREEMENTS**</span>"
) +
theme_360() +
theme(
legend.position = c(0.5, 0.85),
legend.direction = "horizontal",
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.subtitle = element_markdown(family = "Body 360info", face = "plain")
) +
labs(x = NULL, y = NULL, fill = NULL,
title = toupper("Tinder's growing fine print"),
subtitle = paste(
"Since beginning in 2013, Tinder's terms of service have grown from **two policies around",
"4 000 words** into a behomoth comprising **at least nine policies and nearly 30 000 words.**",
sep = "<br>"),
caption = "**CHART:** James Goldie, 360info")
} %>%
save_360plot(here("out", "wordcounts-tinder.png"), shape = "sdtv-landscape")
```
## Spotify
https://www.spotify.com/legal/end-user-agreement/
```{r}
#| label: setupspotify
spotify_css <- c(
paste(
"#content-main .container > h1, #content-main .container > h2, ",
"#content-main .container > p, #content-main .container > li, ",
"#content-main .container td"),
"#pbody")
analyse_spotify <- partial(analyse_platform,
platform = "spotify",
date_seq = seq(as.Date("2011-08-12"), Sys.Date(), by = "month"),
css_tries = spotify_css)
```
```{r}
#| label: scrapespotify
spotify_words <-
analyse_spotify(
primary_url = "https://www.spotify.com/us/legal/end-user-agreement/")
# let's reprocess the ones that had errors:
# spotify_words_copyright <-
# analyse_spotify(
# primary_url = "https://www.spotify.com/us/legal/copyright-policy",
# primary_name = "Copyright Policy",
# scrape_links = FALSE) %>%
# mutate(type = "secondary")
# spotify_words_copyright <-
# analyse_spotify(
# primary_url = "https://www.spotify.com/us/legal/copyright-policy",
# primary_name = "Copyright Policy",
# scrape_links = FALSE) %>%
# mutate(type = "secondary")
# spotify_words_userguidelines <-
# analyse_spotify(
# primary_url = "https://www.spotify.com/legal/user-guidelines",
# primary_name = "Spotify User Guidelines",
# scrape_links = FALSE)
# combine them
spotify_words %>%
filter(!has_errors(scrape)) %>%
filter(str_detect(snapshot_url, "links", negate = TRUE)) %>%
filter(str_detect(snapshot_url, "contact", negate = TRUE)) %>%
# privacy policies after 2018 only partially scraping :(
filter(!(
policy_name == "Privacy Policy" &
target_dt > as.Date("2018-12-12"))) %>%
# after 2020 not scraping properly :(
filter(target_dt <= as.Date("2019-12-12")) %>%
select(-scrape) ->
spotify_words_tidy
# the privacy policy isn't fully scraping since 2019, so we're going to use
# the current figure from then on instead
"https://www.spotify.com/us/legal/privacy-policy/" %>%
read_html() %>%
html_element("#content-main") %>%
html_text2() %>%
paste(collapse = "\n\n") %>%
str_split(regex("\n+")) %>%
pluck(1) %>%
tibble(para = 1:length(.), text = .) %>%
unnest_tokens(word, text) %>%
write_csv(
here("data", "terms", "spotify", "2019-12-12", "privacy-policy-CURRENT.csv")) %>%
print() ->
spotify_privacy_current
# tack the new ones on
spotify_words_tidy %>%
bind_rows(tibble(
type = "secondary",
policy_name = "Privacy Policy",
target_url = "https://www.spotify.com/us/legal/privacy-policy/",
target_dt = seq(as.Date("2019-01-12"), as.Date("2019-12-12"), by = "month"),
word_count = nrow(spotify_privacy_current))) ->
spotify_words_patched
spotify_words_patched %>% write_csv(here("data", "terms", "spotify.csv"))
```
```{r}
#| label: visspotify
spotify_words_patched %>%
group_by(type, target_dt) %>%
summarise(word_count = sum(word_count, na.rm = TRUE)) %>%
ungroup() %>%
mutate(type =
if_else(type == "primary", "Primary terms", "Secondary agreements")) %>%
{
ggplot(.) +
aes(x = target_dt, y = word_count) +
geom_area(aes(fill = type) , position = position_stack(reverse = TRUE)) +
# geom_point(aes(colour = type)) +
# scale_fill_brewer(type = "qual") +
scale_fill_manual(
values = c(
"Primary terms" = "black",
"Secondary agreements" = "#1DB954"),
guide = NULL) +
scale_y_continuous(
labels = scales::label_number(accuracy = 1, scale = 1/1000, suffix = "k words")) +
annotate_360_glasslight(
x = as.Date("2017-06-01"), y = 3500, size = 4,
label = "<span style=\"color:white;\">**PRIMARY TERMS**</span>"
) +
annotate_360_glasslight(
x = as.Date("2017-06-01"), y = 10000, size = 4,
label = "<span style=\"color:black;\">**SECONDARY AGREEMENTS**</span>"
) +
theme_360() +
theme(
legend.position = c(0.5, 0.85),
legend.direction = "horizontal",
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.subtitle = element_markdown(family = "Body 360info", face = "plain")
) +
labs(x = NULL, y = NULL, fill = NULL,
title = toupper("Spotify's growing fine print"),
subtitle = paste(
"Since beginning in 2013, Spotify's terms of service have grown to **over 10 000 words,**",
"including several changing secondary agreements.",
sep = "<br>"),
caption = "**CHART:** James Goldie, 360info")
} %>%
save_360plot(here("out", "wordcounts-spotify.png"), shape = "sdtv-landscape") %>%
save_360plot(here("out", "wordcounts-spotify.svg"), shape = "sdtv-landscape")
```
## Twitter
from 2017: https://twitter.com/tos
Note that Twitter has [a page linking directly to its previous Terms of Service versions](https://twitter.com/en/tos/previous), but most of the links on it appear to be broken.
```{r}
#| label: setupstwitter
twitter_css <- c(
"#twtr-main .ct07-chapters:nth-child(1)",
# bit fragile to specifically select first 70 children,
# but it's hard to use css when multiple sets of terms are in one block!
".Field-items-item :nth-child(-n+70)",
"#pageContent",
"#content")
analyse_twitter <- partial(analyse_platform,
platform = "twitter",
date_seq = seq(as.Date("2007-02-15"), Sys.Date(), by = "month"),
css_tries = twitter_css)
```
```{r}
#| label: scrapetwitter
twitter_words <- analyse_twitter(primary_url = "https://www.twitter.com/tos")
```