Esempio n. 1
0
def trackFriendFeed(args):
	screen_name = args[0]
	password = args[1]
	if password=='' or password==None:
		password = getpass.getpass('Enter '+screen_name+' password: '******'twitterFeed' in locals():
				logger.info('Choon Kee')
				maxid = twitterFeed.maxid
			else:
				logger.info('not choon kee')
				maxid = 0
			
			rateData = TwitterFunctions.getTwitterRateLimitStatus(screen_name, password)
			accountRateLimit = AccountRateLimit(rateData)
			print accountRateLimit
			if int(accountRateLimit.remainingHits) ==0:
				time.sleep(int(accountRateLimit.resetTimeSeconds)-int(time.time())+5)
			data = TwitterFunctions.getFriendTwitterFeed(screen_name, password, maxid, '', 10)
			if not 'twitterFeed' in locals():
				twitterFeed = TwitterFeed(data)
			twitterFeed.update(data)
			displayStatus(twitterFeed)	
			time.sleep(90)
		except TwitterFunctions.TwitterException, ex:
			logger.error(ex)
			continue
Esempio n. 2
0
def getAccountRateLimit(args):
	screen_name = args[0]
	password = args[1]
	if screen_name:
		if password:
			rateData = TwitterFunctions.getTwitterRateLimitStatus(screen_name, password)
			accountRateLimit = AccountRateLimit(rateData)
			print accountRateLimit
		else:
			password = getpass.getpass('Enter '+screen_name+' password: ')
			rateData = TwitterFunctions.getTwitterRateLimitStatus(screen_name, password)
			accountRateLimit = AccountRateLimit(rateData)
			print accountRateLimit
	else:
		rateData = TwitterFunctions.getTwitterRateLimitStatus()
		accountRateLimit = AccountRateLimit(rateData)
		print accountRateLimit
Esempio n. 3
0
	def __getReplyStatus(self, inReplyStatus, level):
		if level > 3:
			return None
		else:
			try:
				data = TwitterFunctions.getTwitterStatus(inReplyStatus)
				#print data
				twitterFeed = TwitterFeed(data, level+1)
				return twitterFeed.statuses[0]
			except TwitterFunctions.TwitterException, ex:
				return None
Esempio n. 4
0
def trackUserFeed(args):
	screen_name=args[0]
	#print screen_name
	while True:
		try:
			if 'twitterFeed' in locals():
				maxid = twitterFeed.maxid
			else:
				maxid = 0
			rateData = TwitterFunctions.getTwitterRateLimitStatus()
			accountRateLimit = AccountRateLimit(rateData)
			print accountRateLimit
			if int(accountRateLimit.remainingHits) ==0:
				time.sleep(int(accountRateLimit.resetTimeSeconds)-int(time.time())+5)
			data = TwitterFunctions.getUserTwitterFeed(screen_name, maxid, '', 10)
			if not 'twitterFeed' in locals():
				twitterFeed = TwitterFeed(data)
			twitterFeed.update(data)
			displayStatus(twitterFeed)
			time.sleep(90)
		except TwitterFunctions.TwitterException, ex:
			logger.error(ex)
			continue
Esempio n. 5
0
# reddit environment variables
reddit_client_id = environ['REDDIT_CLIENT_ID']
reddit_client_secret = environ['REDDIT_CLIENT_SECRET']
reddit_password = environ['REDDIT_PASSWORD']
reddit_user_agent = environ['REDDIT_USER_AGENT']
reddit_username = environ['REDDIT_USERNAME']

#reddit authentation
reddit = praw.Reddit(client_id=reddit_client_id,
                     client_secret=reddit_client_secret,
                     password=reddit_password,
                     user_agent=reddit_user_agent,
                     username=reddit_username)

FILE_NAME = 'static/last_tweet.txt'

redFunc.createImage(reddit, api)
print("did the thing")

while True:
    now = datetime.now()
    current_time = now.strftime("%H:%M")
    if ("23:10" <= current_time <= "23:12"):
        redFunc.createImage(reddit, api)
        print("poggers")
        sleep(60)

    tf.reply(api, FILE_NAME)
    sleep(75)
    print("here")
import TwitterFunctions as TF

path = r"C:\\Users\\Matthew Osborne\\Documents\\python_code\\GeneHackMen\\Data\\"
FileName = r"PittsburghPull"

Queries = [
    "Pittsburgh Shooting", "Synagogue Shooting", "Squirrel Hill",
    "Thoughts and Prayers"
]

TF.SearchTwitter(path, Queries, FileName)
Esempio n. 7
0
def getSearchResult(args):
	query = args[0]
	if query:
		data = TwitterFunctions.getSearchResults(query)
		resultPage = ResultPage(data)
		print str(resultPage)
Esempio n. 8
0
"""

import TwitterFunctions as tf
from collections import defaultdict
import random
import pickle
import re

consumer_key = ""
consumer_secret = ""
access_token = ""
access_token_secret = ""

#%%
#create connection to twitter api
auth_api = tf.twitter_connect(consumer_key, consumer_secret, access_token,
                              access_token_secret)

#get Hadley's account id
hadley = tf.get_user_object("@hadleywickham", auth_api)
hadleyid = hadley[0]
#%% find all of Hadley's followers
level1 = tf.get_follower_ids(hadleyid, auth_api)  #returns 74,820 followers

#filter out followers who follow >100 or <25 accounts
followers = []
#split into batches of 100 for Twitter API
requests = [level1[i:i + 100] for i in range(0, len(level1), 100)]
for request in requests:
    users = tf.get_users(request, auth_api)
    for user in users:
        if user[3] <= 100 and user[3] >= 25:
from amazon_offers import general_links as GL
from amazon_offers import victoria_secret_cosmetics as VCS
from amazon_offers.threadaffiliates import functions as TAFunctions
import TwitterFunctions

# Posting Amazon Affiliate links - ThreadAffiliate Website Links
AffiliateProducts = TAFunctions.fetch_products()

print("Current Task: Posting ThreadAffiliate Website Links on Facebook")
AMZ_helpers.post_on_fb(AMAZON_AFFILIATE_DEALS_ACCESS_TOKENS_LIST,
                       AffiliateProducts,
                       TAFunctions.get_post_message_list(),
                       TAFunctions.WEBSITE_BASE_URL)

print("Current Task: Posting ThreadAffiliate Website Links on Twitter")
TwitterFunctions.post_multiple_tweets(AffiliateProducts)


# Posting Amazon Affiliate links - General Categories
print("Current Task: Posting General Amazon Links")
AMZ_helpers.post_on_fb(AMAZON_AFFILIATE_DEALS_ACCESS_TOKENS_LIST,
                       GL.CHILD_ATTACHMENT_LIST,
                       GL.MESSAGE_TEXT_LIST,
                       AMAZON_AFFILIATE_URL)

# Posting Amazon Affiliate links - Victoria Secret Cosmetics
print("\nCurrent Task: Victoria Secret Cosmetics Links")
AMZ_helpers.post_on_fb(AMAZON_AFFILIATE_DEALS_ACCESS_TOKENS_LIST,
                       VCS.CHILD_ATTACHMENT_LIST,
                       VCS.MESSAGE_TEXT_LIST,
                       AMAZON_AFFILIATE_URL,
clients = Cred.get_twitter_client()[2:]

# These are our queries
Queries = [
    'Dodgers', 'Red Sox', 'LADetermined', 'Ball Park', 'World Series',
    'Game 4', 'Rich Hill', 'Eduardo Rodriguez', 'Home Run', 'Single',
    'Base Hit', 'Dodger Stadium', 'Dodger Dog', 'Machado', 'RedSox',
    'Mookie Betts', 'MLB', 'DoDamage', 'inning', 'Joe Buck', 'Ump'
]

Queries = pd.DataFrame(Queries, columns=['query'])

# Get a since_id as a baseline
since_id = clients[1].get_user('RedSox').status.id_str

# Set the input data
path = r"C:\\Users\\Matthew Osborne\\Documents\\python_code\\GeneHackMen\\Data\\WorldSeries\\"
FileName = "WorldSeries"
Stopper = 600

# make a log file
logging.basicConfig(filename=path + FileName + "_DataPull"
                    '.log',
                    format='%(asctime)s - %(message)s',
                    level=logging.INFO)

logging.info("About to run the Query Script!")
# Pull the data
TF.SearchTwitter(clients, since_id, path, Queries, FileName, Stopper)
logging.info("All done with World Series!")