python 3.x - How to get Twitter followers list? -
i working on web scraping project , follower data public twitter account. find request url can't seem find on twitter. wondering how can list of followers. using python 3
this page describes how it.
you'll need install tweepy , use following code:
import tweepy import time #insert twitter keys here consumer_key ='xxxxxxx' consumer_secret='xxxxxxx' access_token='xxxxxxx' access_secret='xxxxxxx' twitter_handle='handle' auth = tweepy.auth.oauthhandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_secret) api = tweepy.api(auth) list= open('twitter_followers.txt','w') if(api.verify_credentials): print 'we logged in' user = tweepy.cursor(api.followers, screen_name=twitter_handle).items() while true: try: u = next(user) list.write(u.screen_name +' \n') except: time.sleep(15*60) print 'we got timeout ... sleeping 15 minutes' u = next(user) list.write(u.screen_name +' \n') list.close()
Comments
Post a Comment