使用Rvest在R中提取Youtube视频描述

问题描述 投票:0回答:1

我正在尝试使用Rvest提取YouTube视频描述。我知道,仅使用API​​会更容易,但最终目标是使自己更加熟悉Rvest,而不是仅仅获得Video描述。这是我到目前为止所做的:

# defining website
page <- "https://www.youtube.com/watch?v=4PqdqWWSHJY"

# setting Xpath
Xp <- '/html/body/div[2]/div[4]/div/div[5]/div[2]/div[2]/div/div[2]/meta[2]'

# getting page
Website <- read_html(page)

# printing description
html_attr(Description, name = "content")

虽然它确实指向视频描述,但我没有完整的视频描述,而是一个在几行后被切断的字符串:

[1] "The Conservatives and Labour have been outlining their main pitch to voters. The Prime Minister Boris Johson in his first major speech of the campaign said a..."

预期的输出将是完整的描述

"The Conservatives and Labour have been outlining their main pitch to voters. The Prime Minister Boris Johnson in his first major speech of the campaign said a Conservative government would unite the country and "level up" the prospects for people with massive investment in health, better infrastructure, more police, and a green revolution. But he said the key issue to solve was Brexit. Meanwhile Labour vowed to outspend the Tories on the NHS in England. 

Labour leader Jeremy Corbyn has also faced questions over his position on allowing a second referendum on Scottish independence. Today at the start of a two-day tour of Scotland, he said wouldn't allow one in the first term of a Labour government but later rowed back saying it wouldn't be a priority in the early years. 

Sophie Raworth presents tonight's BBC News at Ten and unravels the day's events with the BBC's political editor Laura Kuenssberg, health editor Hugh Pym and Scotland editor Sarah Smith.


Please subscribe HERE: LINK"

有没有办法获得rvest的完整描述?

r youtube rvest
1个回答
0
投票

您可以做:

© www.soinside.com 2019 - 2024. All rights reserved.