-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwls.py
37 lines (22 loc) · 796 Bytes
/
twls.py
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
import tweepy
from conf import read_conf
import re
consumer_key = read_conf("cfg.ini","consumer_key")
consumer_secret = read_conf("cfg.ini","consumer_secret")
access_token = read_conf("cfg.ini","access_token")
access_token_secret = read_conf("cfg.ini","access_token_secret")
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
def get_tweets():
data = tweepy.Cursor(api.user_timeline).items()
tweets = []
for status in data:
tweet_json = status._json
tweet_id = tweet_json['id']
text = status.text
url = f"https://twitter.com/realabja/status/{tweet_id}"
tweets.append([text, url])
# f"{text} \n\n {url}"
return tweets
get_tweets()