Last active
February 18, 2018 20:23
-
-
Save scottythered/c044435bcccba1e301c0c44b631d3b8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tweepy import OAuthHandler | |
from tweepy import API | |
import json | |
from time import sleep | |
import urllib.request | |
import os | |
consumer_key = "XXXXXXXXXXXXXXX" | |
consumer_secret = "XXXXXXXXXXXXXXX" | |
access_token = "XXXXXXXXXXXXXXX" | |
access_token_secret = "XXXXXXXXXXXXXXX" | |
auth = OAuthHandler(consumer_key, consumer_secret) | |
auth.set_access_token(access_token, access_token_secret) | |
api = API(auth) | |
json_input = open('[json file]') | |
data = json.load(json_input) | |
for x in data['tweets']: | |
urllib.request.urlretrieve(x['img'], 'image-temp.jpg') | |
filename = ('image-temp.jpg') | |
api.update_with_media(filename, status=x['text']) | |
os.remove(filename) | |
sleep(1800) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment