rvest 包收获 instagram 粉丝数量?

rvest package to harvest instagram number of followers?

我正在尝试调整 rvest 包中的示例代码,以获取 Instagram 帐户的关注者数量(例如,https://www.instagram.com/bradyellison/)。我尝试使用 selectorgadget 来隔离关注者数量的代码,这给了我这个:._218yx:nth-child(2) ._s53mj。但是我没有得到预期的追随者,也不确定如何调试它。这是我的代码。

# example 
require(rvest)
html <- read_html("https://www.instagram.com/bradyellison/")
athlete_followers <- html_nodes(html, "._218yx:nth-child(2) ._s53mj")
length(athlete_followers)

输出为:

[1] 0

预期关注者为 12.1K。非常感谢帮助。 (我首先尝试使用 Instagram API,但无法正常工作,可能是因为我处于沙盒模式或其他原因。)

您不能 rvest 此页面,因为它不是静态站点,而是通过代码动态生成的(例如尝试 xml_text(html))。要访问 Instagram 数据,您应该使用他们的 API。请在此处查看完整示例:https://www.r-bloggers.com/analyze-instagram-with-r/ .