問題描述
使用 twitteR 包提取 Twitter 句柄而不是屏幕名稱? (Extract Twitter Handles instead of Screen Names using twitteR package?)
我正在使用 twitteR 包,我想獲取我的關注者的 Twitter 句柄而不是屏幕名稱,例如,如果假設用戶 John Biden 是我的關注者之一作為他的屏幕名稱但處理為 @JohnB80,我想要提取@JohnB80。目前我可以得到推特 ID 和屏幕名稱,但不能得到句柄。請幫忙。
參考解法
方法 1:
This (dummy) code should do the trick:
meUser <‑ getUser("myHandle")
followerHandleList <‑ meUser$getFollowers()
This will return a list of Twitter handles (without @'s).
方法 2:
I figured out the solution so what we have to do is:
user <‑ getUser("XXXXX") #Enter the user Screen Name
followers<‑user$getFollowerIDs() #Get the Followers UserIDs
names=lookupUsers(followers) #Get the detailed list about followers
usernames=data.frame(sapply(names, `[[`,"screenName")) #Extract Screen Name
(by Anurag H、Spencer Greenhalgh、Anurag H)