I would like to find all classes used in the webpage below. Is this possible with rvest or will I need anyway some regex/grepl? I am able to scrape the info once I know the name of the class, but for pages with dynamically built class names it would be convenient to have an overview of the class es used.
library(rvest)
doc_url<-"http://curia.europa.eu/juris/document/document.jsf?text=&docid=160583&pageIndex=0&doclang=fr&mode=req&dir=&occ=first&part=1&cid=676771"
page<-read_html(doc_url)
language<- page%>%html_nodes(".C49FootnoteLangue")%>%html_text()
Converting @hadley's comment to a CW answer, you can get a vector of all the classes by using the *
wildcard.
Thus, the approach would look like:
page <- read_html(doc_url)
page %>%
html_nodes("*") %>%
html_attr("class") %>%
unique()
# [1] NA "component" "waitBlock"
# [4] "waitBlockContainer" "toggle_img" "btn_impression"
# [7] "document_language" "outputEcli" "C19Centre"
# [10] "C71Indicateur" "C02AlineaAltA" "C72Alineadroite"
# [13] "C75Debutdesmotifs" "C01PointnumeroteAltN" "C04Titre1"
# [16] "C03Tiretlong" "C05Titre2" "C06Titre3"
# [19] "C07Titre4" "C48DispositifIntroduction" "C08Dispositif"
# [22] "C77Signatures" "C49FootnoteLangue"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With