Hendrik
Hendrik

Reputation: 321

Scrape title attribute from CSS with rvest

I use rvest to scrape web data. I have the following CSS code from a website:

<abbr class="intabbr" title="2.856.890">2,9M</abbr>

I scrape this data with

library(rvest)
library(dplyr)
n <- read_html("https://www.last.fm/de/music/Fang+Island")
n %>%
html_node("abbr") %>%
html_text()

This gives me "2M", but what I would like to get is the "2.856.890".

I am not very knowledgeable in CSS: Is it possible to get the information which I want by the changing the expression in html_node()?

This post suggests that it is not possible, however this one suggests that it might be possible since it pops up as a tooltip on the page?

Upvotes: 0

Views: 715

Answers (1)

Luiz Rodrigo
Luiz Rodrigo

Reputation: 936

Use html_attr to get a tag's attribute:

n %>%
  html_node("abbr") %>%
  html_attr("title")

Upvotes: 1

Related Questions