Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment