将@ hadley的注释转换为CW答案,您可以使用*
通配符获取所有类的向量.
因此,该方法看起来像:
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"