【发布时间】:2021-11-27 01:25:15
【问题描述】:
我编写了下面的代码来提取 FLOTUS 在link 上发表的所有演讲。代码如下:
library(rvest)
library(purrr)
url_base <- "https://www.presidency.ucsb.edu/documents/presidential-documents-archive-guidebook/remarks-and-statements-the-first-lady-laura-bush?page=%d"
map_df(1:17, function(i) {
# simple but effective progress indicator
cat(".")
pg <- read_html(sprintf(url_base, i))
data.frame(name=html_text(html_nodes(pg, ".views-field-title-1.nowrap")),
title=html_text(html_nodes(pg, "td.views-field-title")),
year=html_text(html_nodes(pg, ".date-display-single")),
stringsAsFactors=FALSE)
}) -> flotus
我也想用这段代码来提取相应演讲的文本。有谁知道如何使用我已经编写的代码来做到这一点?如果是这样,那会是什么样子?
【问题讨论】:
标签: r web-scraping purrr rvest