Closed Rayan20218 closed 2 years ago
data
import json import random import time import tweepy
consumer_key = 'xxxxx' consumer_secret = 'xxxxx' access_token= "xxxxx" access_secret = "xxxxxx" auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_secret) api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)
def main():
with open("azkar.json", "r") as read_file:
data = json.load(read_file)
random_azkar = random.choice(data)
category = random_azkar["category"]
zekr = random_azkar["zekr"]
l = len(zekr)
print(l)
while l > 160:
random_azkar = random.choice(data)
category = random_azkar["category"]
zekr = random_azkar["zekr"]
l = len(zekr)
print(l)
print("التصنيف: "+category+"\nالذكر: "+zekr+"\n")
#نشر الذكر في تويتر
api.update_status("التصنيف: "+category+"\nالذكر: "+zekr+"\n#اذكار")
print("Tweeted")
while True: main() time.sleep(1800)
U