R로 배우는 웹 스크레이핑
Timo Grossenbacher
Instructor
//div/p[@class = "blue"] (동일: div > p.blue)a에 special 클래스를 가진 자식을 포함한 div만 선택
html %>%
html_elements(xpath = '//p')
# CSS selector equivalent: p
html %>%
html_elements(xpath = '//body//p')
# CSS selector equivalent: body p
html %>%
html_elements(xpath = '/html/body//p')
# CSS selector equivalent: html > body p

html %>%
html_elements(xpath = '//div/p')
# CSS selector equivalent: div > p

html %>%
html_elements(xpath = '//div[a]')
# CSS selector equivalent: none
/ 또는 //span, a 같은 HTML 타입[...]//span/a[@class = "external"] (CSS: span > a.external) //*[@id = "special"]//div (CSS: #special div 또는 *#special div)R로 배우는 웹 스크레이핑