Skip to content

Commit 273b1bd

Browse files
committed
your turn
1 parent cbdb3bc commit 273b1bd

File tree

4 files changed

+769
-0
lines changed

4 files changed

+769
-0
lines changed

02_yourturn.Rmd

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: "Your Turn"
3+
output: html_notebook
4+
---
5+
6+
```{r}
7+
library(tidyverse)
8+
library(rvest)
9+
```
10+
11+
12+
Gather the HTML for
13+
14+
http://www.vondel.humanities.uva.nl/ecartico/persons/37598
15+
16+
17+
```{r}
18+
mypage <- read_html("_________________")
19+
mypage
20+
```
21+
22+
23+
Display all the href attributes for the anchor text on the collected page
24+
25+
```html
26+
<a href="https://foo.com">my link</a>
27+
```
28+
29+
```{r}
30+
mypage %>%
31+
html_nodes("____") %>%
32+
html_attr("____")
33+
```
34+
35+
36+
Practice using selector gadget and gather only the text from the list items in the sections: Marriages, Occupation(s), and Occupational address(es).
37+
38+
39+
```{r}
40+
mypage %>%
41+
html_nodes("_______") %>%
42+
html_text()
43+
```
44+
45+
46+
What are the main subject headings on the page?
47+
48+
```{r}
49+
mypage %>%
50+
html_nodes("___") %>%
51+
html_text()
52+
```

02_yourturn.nb.html

Lines changed: 353 additions & 0 deletions
Large diffs are not rendered by default.

02a_yourturn_answers.Rmd

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: "Your Turn"
3+
output: html_document
4+
---
5+
6+
```{r}
7+
library(tidyverse)
8+
library(rvest)
9+
```
10+
11+
12+
Gather the HTML for
13+
14+
http://www.vondel.humanities.uva.nl/ecartico/persons/37598
15+
16+
17+
```{r}
18+
mypage <- read_html("http://www.vondel.humanities.uva.nl/ecartico/persons/37598")
19+
mypage
20+
```
21+
22+
23+
Display all the href attributes for the anchor text on the collected page
24+
25+
```html
26+
<a href="https://foo.com">my link</a>
27+
```
28+
29+
```{r}
30+
mypage %>%
31+
html_nodes("a") %>%
32+
html_attr("href")
33+
```
34+
35+
Practice using selector gadget and gather only the text from the list items in the sections: Marriages, Occupation(s), and Occupational address(es).
36+
37+
38+
```{r}
39+
mypage %>%
40+
html_nodes("h2+ ul a") %>%
41+
html_text()
42+
```
43+
44+
45+
What are the main subject headings on the page?
46+
47+
```{r}
48+
mypage %>%
49+
html_nodes("h2") %>%
50+
html_text()
51+
```
52+

02a_yourturn_answers.html

Lines changed: 312 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)