Last active
June 22, 2018 08:01
-
-
Save sorashido/b13c7d6cc5978c8880d6c852585bc573 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from TwitterAPI import TwitterAPI, TwitterPager | |
import csv | |
SCREEN_NAME = 'McDonaldsJapan' | |
CONSUMER_KEY = 'xxx' | |
CONSUMER_SECRET = 'xxxxxx' | |
api = TwitterAPI(CONSUMER_KEY, | |
CONSUMER_SECRET, | |
auth_type='oAuth2') | |
pager = TwitterPager(api, | |
'statuses/user_timeline', | |
{'screen_name':SCREEN_NAME}) | |
csvFile = open('2018.csv', 'a') | |
csvWriter = csv.writer(csvFile) | |
count = 0 | |
for item in pager.get_iterator(): | |
print(item) | |
csvWriter.writerow([item['created_at'],item['user']['screen_name'], item['text'] if 'text' in item else item]) | |
count += 1 | |
if count > 2: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment