#导入包
library(rvest)
library(stringr)
library(xml2)
#检索评论得到的url
url <- "https://movie.douban.com/subject/26794435/comments?status=P"
#读取html
web<-read_html(url,encoding="UTF-8")
web
#获取第一页的评论内容(直接看标签正则)
comment_date <- web %>% html_nodes("div p span.short") %>% html_text()
comment_date
str_replace(comment_date, " \n", "") #替换
str_replace(comment_date, "\n", "")
#数据框返回
date.frame(comment_date)
运行结果显示 没有"date.frame"这个函数
新手跪求各位大佬解答


雷达卡


京公网安备 11010802022788号







