SASpencer SASpencer - 1 year ago 89
R Question

rvest package to harvest instagram number of followers?

I'm trying to adapt the example code in the

package for getting number of followers for an account on instagram (e.g.,
). I tried using
to isolate code for number of followers, which gave me this:
._218yx:nth-child(2) ._s53mj
. But I don't get the expected followers back, and not sure how to debug this. Here's my code.

# example
html <- read_html("")
athlete_followers <- html_nodes(html, "._218yx:nth-child(2) ._s53mj")

Output is:

[1] 0

Expected followers are 12.1K. Would really appreciate help. (I've tried using the Instagram API for this first, but couldn't get it to work, perhaps because I'm in sandbox mode or something.)

Answer Source

You can't rvest this page because it's not a static site, rather it's generated dynamically via code (e.g. try xml_text(html)). To access Instagram data you should use their API. See full example here: .

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download