问题描述
我有个篮球运动员的名字,想通过Google的建议答案来确定他们的出生日期。如何从Google搜索中获得建议的生日?我的想法是遍历名称,并始终将名称添加到url,然后以某种方式抓取建议的生日(总是作为第一个建议)并将其保存到数据框中的列中(或将生日作为向量也足够)。
一个例子:
require(rvest)
mydt <- data.table(names = c('Michael Jordan','Allen Iverson','Larry Bird'),birth_dates = as.character(NA))
for (i in 1:nrow(mydt)) {
search_name <- mydt$names[i]
url <- paste0('https://www.google.com/search?q=',gsub(' ','%20',search_name),'%20birth%20date')
f@R_502_6447@t_page <- read_html(url)
page_nodes <- html_nodes(f@R_502_6447@t_page,xpath = "//div/div/div/a/div[not(div)]")
# Now I don't kNow how to continue to get the birth date
# Assuming the variable "birth_date" would be the scraped date I would want to store it then in the data frame
mydt$birth_dates[i] <- birth_date
}
我要么想要一个由三个出生日期(“ 1963-02-17”,“ 1975-06-07”,“ 1956-12-07”)组成的向量,要么在第二个数据知名度列中。谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)