digitalmethodsinitiative / dmi-tcat

Digital Methods Initiative - Twitter Capture and Analysis Toolset
Apache License 2.0
365 stars 114 forks source link

Get user's network. #232

Open fubespu opened 7 years ago

fubespu commented 7 years ago

Hi,

first of all, let me thank you again for such a great software and keeping it alive (some quotes to it would appear in a journal about Political Communication and in an other major election analysis book).

However, there are some features I miss and which I think would be a great contribution for many scholars. Obtaining the network (followers of followers, also known as 1.5 network) for certain users would be a great asset for the Gephi usage and some theorical frames (communication bubbles, Sunstein, 2006).

The aim is to obtain a full network of followers for certain users. A typical use is obtaining the followers from certain political profiles (leaders, parties, media, institutions, etc...) in order to construct possible audiences.

At the moment, the only software that is capable of this is NodeXL (which I've been using for a long time) but it doesn't satisfy all other research needs (which TCAT does) and doesn't do it very well too (to much noise you can't get of the network when exporting to Gephi, i.e.: friends, in_reply_to, etc...).

I can imagine other features that would be also very nice:

I can contribute to this with the following script which gets you all followers for a giving user (Python, Tweepy):

from __future__ import absolute_import, print_function

import tweepy
import time

consumer_key="xxxxxxxxxxxxxxxxx"
consumer_secret="xxxxxxxxxxxxxxxxx"

access_token="xxxxxxxxxxxxxxxxx"
access_token_secret="xxxxxxxxxxxxxxxxx"

accountvar = input("Account name: ")

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.secure = True
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)

users = tweepy.Cursor(api.followers, screen_name=accountvar).items()

while True:
    try:
        user = next(users)
    except tweepy.TweepError:
        time.sleep(60*15)
        user = next(users)
    except StopIteration:
        break
    print ("@" + user.screen_name)
ErikBorra commented 7 years ago

Hi @fubespu

we could make scripts for both follow and followed by relations. This would involve quite some steps though.

In the backend

In the frontend

Currently this does not have high priority. Comments with suggestions and pull requests are encouraged though.