Get data from Twitter using Tweepy

Tweepy is useful for hitting the Twitter API in Python Tweepy Official Github

It supports almost all (maybe all?) APIs so you can hit anything.

For Consumer key and Access token, here may be detailed.

Example

Get the ID of a user's follower

api_test.py


import sys
import tweepy

consumer_key = sys.argv[1]
consumer_secret = sys.argv[2]
access_token = sys.argv[3]
access_token_secret = sys.argv[4]

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

api = tweepy.API(auth)

print api.followers_ids('yamaguchiyuto')
$ python api_test.py [consumer key] [consumer secret] [access token] [access token secret]
[90429667, 202652239, 42027820, 19596021, 2195153192, 117687842, 2258629297, 1406786214, 16555745, 14842736, 66415991, 434223, 2346982724, 2333008268, 831055380, 93408266, 17268882, 162083740, 504019119, 228762898, 11722222, 229762645, 132796590, 5623272, 25038224, 1597143732, 110659688, 10121792, 404563048, 181644477, 314346343, 608353, 235254268, 433214780, 6164512, 591682167, 91910392, 44864602, 19161647, 189232458, 396851678, 383715259, 1290571964, 7229862, 337344406, 636211860, 143365117, 16271729, 138080138, 90562000, 377193688, 107033612, 1193350651, 552235322, 533047270, 626637703, 13602752, 1113534024, 513755822, 190063726, 869907272, 386865386, 68339158, 159665742, 901697208, 108157800, 159734839, 815082048, 44519653, 410733253, 847537580, 340900181, 18631141, 89664770, 94797531, 54506895, 147195422, 61168347, 11865812, 457499777, 146706476, 752402191, 753169801, 14488235, 91264606, 17571464, 5597892, 5605872, 426486052, 31390654, 74172008, 49980803, 63187556, 5530022, 97451914, 5528512, 144551657, 58169007, 456506958, 49631101, 178020965, 221644210, 560139598, 8123222, 96398492, 207086775, 186427246, 46570373, 460160272, 127436086, 540747882, 201246351, 291519868, 108860769, 166424351, 132092733, 393374629, 284485000, 136290282, 8424582, 166255351, 87977515, 52575494, 268667702, 135520819, 209969174, 498912433, 496731820, 17916105, 144728570, 344460636, 45550596, 17916220, 96698109, 45092094, 248132475, 214807446, 45122807, 8216412, 187127726, 174820685, 147995371, 108201390, 365348844, 226482519, 116358272, 60355627, 281121335, 56304040, 68645532, 252214105, 248993119, 370616354, 202617625, 5904392, 314036763, 454902363, 119320073, 169429386, 135457590, 265418637, 54505412, 9492602, 94223074, 211548465, 266770141, 137303807, 57221533, 5756062, 12263082, 395771001, 9074002, 140365856, 97645491, 114654723, 156286290, 8428752, 316154491, 222325990, 374043063, 134122371, 76690610, 121094836, 43491198, 135831308, 384080093, 90130178, 270844208, 20692391, 120722054, 64721692, 106022456, 17724558, 279072297, 213220347, 320642436, 57039741, 166399861, 187942923, 265305533, 185990526, 38007036]

Recommended Posts

Get data from Twitter using Tweepy
Get structural data from CHEMBLID
Get celebrity tweet history from twitter
Get Salesforce data using REST API
Get data from Quandl in Python
I tried to get data from AS / 400 quickly using pypyodbc
Get data from your website on a regular basis using ScraperWiki
I tried to get data from AS / 400 quickly using pypyodbc Preparation 1
[Note] Get data from PostgreSQL with Python
Get tweets containing keywords using Python Tweepy
Get images by keyword search from Twitter
Tweet from python with Twitter Developer + Tweepy
Get data from Cloudant with Bluemix flask
Get Twitter bookmarks on CentOS using Selenium
Get Youtube data in Python using Youtube Data API
Get images from specific users on Twitter
Get data from an oscilloscope with pyVISA
Get Twitter Trends
Get Twitter userData
Get time series data from k-db.com in Python
[Python] Get all comments using Youtube Data API
Send data from Raspberry Pi using AWS IOT
Encrypt / decrypt data from golang using Azure KeyVault
Get 10 or more data from SSM parameter store
Get data files from elsewhere during pip install
Data analysis using xarray
Try using COVID-19's open data from Yokohama / Tokyo / Osaka
Extract data from S3
Get Amazon RDS (PostgreSQL) data using SQL with pandas
Visualize network data using Cytoscape from IPython Notebook Part 1
Data analysis using Python 0
Get LEAD data using Marketo's REST API in Python
Get data from GPS module at 10Hz in Python
Data cleansing 2 Data cleansing using DataFrame
[Python] Get insight data using Google My Business API
Get Gzip-compressed data on-memory
Search Twitter using Python
I tried reading data from a file using Node.js.
Get files from Linux using paramiko and scp [Python]
Try using Tweepy [Python2.7]
Get data from database via ODBC with Python (Access)
Get pdf, png from Tableau server using TSC (Tableau Server Client).
Visualize plant activity from space using satellite data and Python
[Tweepy] Re: Twitter Bot development life starting from zero # 1 [python]
Get data using Ministry of Internal Affairs and Communications API
Hit REST in Python to get data from New Relic
[Python] Random data extraction / combination from DataFrame using random and pandas
How to get temperature from switchBot thermo-hygrometer using raspberry Pi
Flatten using Python yield from
Get Twitter timeline with python
Export 3D data from QGIS
Extract Twitter data with CSV
Get similar posts using Doc2Vec
Twitter post from command line
Select features using text data
Get Youtube data with python
Post to Twitter using Python
Get clipboard from Maya settings
Data visualization method using matplotlib (1)
Get GitHub information using PyGithub
Data visualization method using matplotlib (2)