-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwitterutil.py
More file actions
41 lines (33 loc) · 1.19 KB
/
twitterutil.py
File metadata and controls
41 lines (33 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: iso-8859-1 -*-
import requests
import tweepy
import json
from tweepy import OAuthHandler
import pdb
twitter_id = '753763924131123200' #substituir pelo twitter id do usuário: http://mytwitterid.com/
total_tweets = 10
consumer_key = 'ME3gfC1qGFyVyk81CNHJa5EWe'
consumer_secret = '5LuJl9HxWxR2a0R7zoVSWzTWg0KFZZkwHg2y08YbUDgTCB5epD'
access_token = '753763924131123200-Ec4hPYqm9dBgEN9FRCIVu9VZKjIAaYp'
access_secret = 'hBrcLank8Q6a42lfgx33K5ZyvUuJpk0PbCyW46DiHefhq'
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
api = tweepy.API(auth)
def getPostsUser():
tweets = []
api = tweepy.API(auth)
for line in tweepy.Cursor(api.user_timeline).items(total_tweets):
tweet = json.loads(json.dumps(line._json))
tweets.insert(0, tweet)
return tweets
def getPostsAmigos():
tweets = []
for line in tweepy.Cursor(api.home_timeline).items(total_tweets):
tweet = json.loads(json.dumps(line._json))
#pdb.set_trace()
if tweet['id'] != twitter_id:
tweets.insert(0, tweet)
return tweets
if __name__ == "__main__":
print (getPostsUser())
print (getPostsAmigos())