Skip to content

Instantly share code, notes, and snippets.

@scottythered
Last active February 18, 2018 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottythered/c044435bcccba1e301c0c44b631d3b8c to your computer and use it in GitHub Desktop.
Save scottythered/c044435bcccba1e301c0c44b631d3b8c to your computer and use it in GitHub Desktop.
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