Reputation: 1613
I have webscraped this https://www.ecb.europa.eu/press/pressconf/2019/html/ecb.is190912~658eb51d68.en.html. The problem is that the text is divided into as many paragraphs as SelectorGadget selected. Instead, I would like it to be one single text.
I have the following code that you can replicate to better understand the problem:
url_ecb_190124 <- "https://www.ecb.europa.eu/press/pressconf/2019/html/ecb.is190124~cd3821f8f5.en.html"
ecb_190124 <- read_html(url_ecb_190124)
statements1 <- html_text(html_nodes(ecb_190124, ".ecb-pressCategory~ p+ p"))
Unfortunately, "statements1" takes [86] paraghraps (86 obs.), whereas I just want it to be one single observation. I tried without results all the commands I am ware of ("paste", "rbind", etc.).
Does anyone know how I can sort it out?
Thanks a lot!
Upvotes: 3
Views: 89
Reputation: 252
Just use paste
paste(statements1, collapse = "")
when you add the collapse parameter it combines all elements in a vector and separates them with what you put in the quotes.
Upvotes: 1