-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscheduleTweet.py
More file actions
48 lines (38 loc) · 1.09 KB
/
scheduleTweet.py
File metadata and controls
48 lines (38 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
46
47
48
import logging
import time
import requests
import json
import schedule
import tweepy
from time import sleep
# API authorization
auth = tweepy.OAuthHandler("rQRXP6L2eLbSvnwkI5TYwLgro", "VQdYvlyYDfpmZHJgIUOYLW6T0dhjkr4oE97cBygaswc7dcK2ve")
auth.set_access_token("844280085167296512-Q2zXATvYf75fp02EMEy7EFNTd9Y8MQD","Jl9Z0gvgjUzIDS8MS7ydV9LgHtzmDXC90PcNeZgQN5OBJ")
api = tweepy.API(auth)
#API verification
try:
api.verify_credentials()
print("Authentication successful!");
except:
print("Error during Authentication.")
# Get User
user = api.get_user('mayurkukreja26')
print(user.screen_name)
# user's followers count
print(user.followers_count)
# logger = logging.getLogger()
# logging.basicConfig(level=logging.INFO)
# logger.setLevel(logging.INFO)
def scheduler():
time.sleep(3)
url = "https://api.quotable.io/random"
response = requests.get(url)
res = json.loads(response.text)
print(res)
api.update_status(res['content'])
scheduler()
# Automation
#schedule.every().day.at("02:56").do(scheduler, "Done @ 02:56")
#while True:
#schedule.run_pending()
#time.sleep(40)