使用 twitteR 包提取 Twitter 句柄而不是屏幕名稱? (Extract Twitter Handles instead of Screen Names using twitteR package?)


問題描述

使用 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 HSpencer GreenhalghAnurag H)

參考文件

  1. Extract Twitter Handles instead of Screen Names using twitteR package? (CC BY‑SA 2.5/3.0/4.0)

#R #twitter






相關問題

如何將均值、標準差等函數應用於整個矩陣 (How to apply mean, sd etc. function to a whole matrix)

Tạo các thùng của mỗi hàng trong bảng và vẽ hình thanh ngăn xếp trong R (Make bins of each table row and draw stack bar figure in R)

Reading not quite correct .csv file in R (Reading not quite correct .csv file in R)

包'treemap'中的線條粗細 (Thickness of lines in Package ‘treemap’)

是否需要帶有 awk 的預處理文件,或者可以直接在 R 中完成? (Is preprocessing file with awk needed or it can be done directly in R?)

rpivotTable 選擇元素下拉菜單 (rpivotTable select elements drop down menu)

優化性能 - Shiny 中的大文件輸入 (Optimizing Performance - Large File Input in Shiny)

數值取決於所應用的應用系列,R (Numeric values depending of apply family applied, R)

如何記錄全年的值? (How to note the values across year?)

R中的線性搜索 (Linear search in R)

在 dplyr/purrr 工作流程中動態連接多個數據集 (Dynamically join multiple datasets in a dplyr/purrr workflow)

如何將行值更改為列名 (R) (How change Row values to Column names (R))







留言討論