We will continue where we left off in the first challenge earlier today. Copy and paste your code below (or check the solutions) to compile a data frame with campaign speeches by Hillary Clinton:

```{r}
url <- "http://www.presidency.ucsb.edu/2016_election_speeches.php?candidate=70&campaign=2016CLINTON&doctype=5000"
## READ HTL CODE ##
library(rvest)
html <- read_html(url)
tab <- html_table(html, fill=TRUE)
clinton <- tab[[8]]
names(clinton) <- c("actor", "date", "title")
clinton <- clinton[-1,]
```

As we saw, this table will not contain the URL, but we will need them this challenge. You should now be able to know how to use selectorGadget to identify the CSS selector of the URLs for each campaign speech, and then write code to extract all the URLs in a vector. As a last step here, add that vector as an additional variable in the data frame.


```{r}
urls <- html_attr(html_nodes(html, ".listdate a"), "href")
urls <- str_replace(urls, "\\.\\.", "http://www.presidency.ucsb.edu/ws")
```

Now let's try to scrape the text from the first campaign speech. Here's a [direct link](http://www.presidency.ucsb.edu/ws/index.php?pid=96348) to it, but in a second we'll try to generalize this step.Extract the title of the speech.

```{r}
first <- "http://www.presidency.ucsb.edu/ws/index.php?pid=96348"

## CODE HERE ##

```

Scrape the entire speech and save it as a single string. This one is a bit harder because of the way the website is structured, but searching in the underlying html code for parts of the text should give you a clue.

```{r}

```

After successfully scraping the speech, create a function called `scrape_speech` that will take a URL as argument and return the text as a single string. Test that it works with the URL provided above.


```{r}


```

Now, create an empty variable in the data frame you created earlier. You can call it `text`. Using a loop, scrape the text for the first 20 speeches in the website. Make sure you add some time between iterations of the loop to make sure we don't overload the website with requests!


```{r}

```

Repeat the process above, but this time with the campaign speeches by Donald Trump, available [here](http://www.presidency.ucsb.edu/2016_election_speeches.php?candidate=45&campaign=2016TRUMP&doctype=5000), and store it in a data frame called `trump`.

```{r}


```

As a final step, put the two datasets together with `rbind` and save the resulting dataset into disk with `write.csv`. Don't worry about collecting all the speeches -- we'll come back to this example later in the course and I'll provide the full speech dataset.


```{r} 


```





