You can store the results of redditScrapper.py
to a file, and let minerTweets.py
take the data from there:
with open('test.txt', 'w') as fp:
data = json.load(response)
json.dump(data, fp)
With test.txt
stored in the same directory. Now, the only thing left is to read it:
with open('test.txt') as fp:
api = Twython(CONSUMER_KEY,CONSUMER_SECRET,ACCESS_KEY,ACCESS_SECRET)
data = json.load(fp)
api.update_status(data['data']['children'][3]['data']['title'])
Edit: If you want to merge the script, it's not so hard.
import urllib2
import json
from twython import Twython
CONSUMER_KEY = 'XXXXXXXXXXXXXXXX'
CONSUMER_SECRET = 'XXXXXXXXXXXXXXXX'
ACCESS_KEY = 'XXXXXXXXXXXXXXXX'
ACCESS_SECRET = 'XXXXXXXXXXXXXXXX'
# get remote string
url = 'http://www.reddit.com/new.json?sort=new'
response=urllib2.urlopen(url)
# interpret as json
data = json.load(response)
#print(data)
response.close()
api = Twython(CONSUMER_KEY,CONSUMER_SECRET,ACCESS_KEY,ACCESS_SECRET)
d = data['data']['children'][3]['data']
title = d['title']
permalink = d['permalink']
subreddit = d['subreddit']
api.update_status(status=title+permalink+subreddit) #or you can post this as different
#status, depends on how you'd like to format the tweet.