-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-favorite
More file actions
45 lines (33 loc) · 1.09 KB
/
create-favorite
File metadata and controls
45 lines (33 loc) · 1.09 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
42
43
44
45
from requests_oauthlib import OAuth1Session
import json
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACCESS_TOKEN = ''
ACCESS_TOKEN_SECRET = ''
twitter_api = OAuth1Session(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
import tweepy
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
api = tweepy.API(auth,wait_on_rate_limit = True, timeout= 50000)
# Create Favorites
def CreateLikes():
import time
time_limit_sec = 60
start_time = time.time()
count = 10
query = input('Input Search Term ')
for q in query:
print("Now:QUERY-->>{}".format(q))
search_result = tweepy.Cursor(api.search,
q = query,
count = count,
languages=['en'],
include_entities = True,
tweet_mode = 'extended').items()
for status in search_result:
tweet_id = status.id
try:
api.create_favorite(tweet_id)
except:
pass
CreateLikes()