Ejemplo n.º 1
0
def tweet_data(tweet):
	if "RT @" not in tweet['text']:
		try:
			print( '@%s tweeted: %s\nFavorites: %d  Retweets: %d' %\
			( tweet['user']['screen_name'], tweet['text'],tweet['favorite_count'],\
			tweet['retweet_count'] ))
			post = Post()	
			post.title = tweet['text']
			print post.title
			post.posted_by = tweet['user']['screen_name']
			print post.posted_by
			post.date_time = tweet["created_at"].replace(" +0000","")
			print post.date_time
			post.retweets = tweet['retweet_count']
			print post.retweets
			post.favorites=tweet['favorite_count']
			print post.favorites
			post.ups=None
			print post.ups
			post.from_twitter = True
			print post.from_twitter
			post.post_link = "http://www.twitter.com/"+str(tweet['user']['screen_name'])+"/status/"+str(tweet['id'])
			print post.post_link
			post.link=regex_tweet_link(tweet)
			print post.link
			post.save()
			return post
		except:
			print "saving failed!"
			import sys
			print sys.exc_info()
Ejemplo n.º 2
0
def reddit_data(x):
	post = Post()
	post.title = x.title
	post.link = x.url
	post.posted_by = x.fullname
	post.date_time = datetime.datetime.fromtimestamp\
					(int(x.created_utc)).strftime('%c')
	post.ups=x.ups
	post.retweets=None
	post.favorites=None
	post.from_twitter=False
 	post.post_link = "http://www.reddit.com/"+str(x.id)
	post.save()
	return post