def main(): #workingdir = os.getcwd() #Raybotdir = os.listdir(workingdir+"/AllBotConfig/") Raybotdir = os.listdir("https://guarded-chamber-8525.herokuapp.com/AllBotConfig/") for ig in Raybotdir: my_bot = TwitterBot("/AllBotConfig/"+ig) my_bot.auto_fav("#Rayviewz", count=30) #Automatically favourite any tweet with a specitfic phrase. my_bot.auto_rt("#Rayviewz", count=10) # Automatically retweet any tweet with a specitfic phrase.
def retweet(): # create an instance of the TwitterFollowBot # by default, the bot will look for a configuration file called config.txt in your current my_bot = TwitterBot() # autoretweets the 5(count) latest tweets that matches the hashtag my_bot.auto_rt("#AppleEvent", count=5) return {'message': 'retweeted successfully'}
def unfollow(): uf_bot = TwitterBot() uf_bot.sync_follows() uf_bot.auto_follow_followers() uf_bot.auto_unfollow_nonfollowers() uf_bot.auto_mute_following()
def follow_keyword(keyword, number): f_bot = TwitterBot() f_bot.sync_follows() f_bot.auto_follow(keyword, count = number) f_bot.auto_follow_followers() f_bot.auto_mute_following()
class PyBot: def __init__(self): self.bot = TwitterBot() self.bot.sync_follows() def work(self, phrase, long): start = time.time() result = self.bot.search_tweets(phrase, 100, "recent") for tweet in result["statuses"]: try: # don't retweet your own tweets if tweet["user"]["screen_name"] == self.bot.BOT_CONFIG[ "TWITTER_HANDLE"]: continue if long: self.bot.wait_on_action() # self.bot.wait_on_action() result = self.bot.TWITTER_CONNECTION.statuses.retweet( id=tweet["id"]) print("Retweeted: %s" % (result["text"].encode("utf-8"))) result = self.bot.TWITTER_CONNECTION.favorites.create( _id=tweet["id"]) word = str("Favorited: %s" % (result["text"].encode("utf-8"))) if time.time() - start > 120 and long: return word elif time.time() - start > 10 and not long: return word print("%s" % (time.time() - start)) # when you have already retweeted a tweet, this error is thrown except TwitterHTTPError as api_error: # quit on rate limit errors if "rate limit" in str(api_error).lower(): print("You have been rate limited. " "Wait a while before running the bot again.") return print("Error: %s" % (str(api_error))) def stop_work(self): raise SystemExit()
def auto_follow(self): self.label2 = Label(self.fourthFrame, text="Loading") self.label2.grid(row=6, columnspan=2, pady=10) self.canvas = Canvas(self.fourthFrame, width=465, height=22, bg="white") self.canvas.grid(row=7, columnspan=2) fill_line = self.canvas.create_rectangle(1.5, 1.5, 0, 23, width=0, fill="green") tkinter.messagebox.showinfo( title="Information", message= "Processing, it takes around 10s - 60s to follow one account. Please wait unitl it finishes!" ) keyword = self.entry1.get() num = self.entry2.get() my_bot = TwitterBot("config2.txt") my_bot.sync_follows() my_bot.auto_follow(keyword, self.canvas, self.master, fill_line, count=num) tkinter.messagebox.showinfo(title="Information", message="Done!")
def main(): #workingdir = os.getcwd() #Raybotdir = os.listdir(workingdir+"/AllBotConfig/") Raybotdir = os.listdir( "https://guarded-chamber-8525.herokuapp.com/AllBotConfig/") for ig in Raybotdir: my_bot = TwitterBot("/AllBotConfig/" + ig) my_bot.auto_fav( "#Rayviewz", count=30 ) #Automatically favourite any tweet with a specitfic phrase. my_bot.auto_rt( "#Rayviewz", count=10 ) # Automatically retweet any tweet with a specitfic phrase.
from TwitterFollowBot import TwitterBot import time my_bot = TwitterBot() count = 0 while True: my_bot.sync_follows() my_bot.auto_follow("gestion proyecto") #my_bot.auto_follow("project management") my_bot.auto_follow("#ludificacion") my_bot.auto_follow("#gamification") my_bot.auto_follow("#liderazgo") my_bot.auto_follow("#productividad") #my_bot.auto_follow("basecamp") #my_bot.auto_follow("trello") my_bot.auto_unfollow_nonfollowers() count+=1 time.sleep(60*60*2) ''' while count < 20: my_bot.auto_rt("gestion proyecto", count=1) time.sleep(60*10) my_bot.auto_rt("#equipo", count=1) time.sleep(60*10)
from TwitterFollowBot import TwitterBot my_bot = TwitterBot() my_bot.auto_follow("tomorrowland", count=10) my_bot.auto_follow("sxsw", count=10) my_bot.auto_follow("ultra miami", count=10) my_bot.auto_follow("rave booty", count=10) my_bot.auto_follow("festival", count=10) my_bot.auto_follow("dallas", count=10) my_bot.auto_follow("austin", count=10) my_bot.auto_follow("snapchat story", count=10) my_bot.auto_follow("spotify", count=10) my_bot.auto_follow("soundcloud", count=10)
from TwitterFollowBot import TwitterBot my_bot = TwitterBot() my_bot.sync_follows() my_bot.auto_follow("mtb")
from TwitterFollowBot import TwitterBot #create a instance of twitter bot my_bot = TwitterBot() #sink with the local cache to find the exixting followers my_bot.sync_follows() #auto unfollow people who don't follow my_bot.auto_unfollow_nonfollowers() #auto follow the twitter handle that tweets on the given topic my_bot.auto_follow("docker", count=05) my_bot.auto_follow("devops", count=05) my_bot.auto_follow("kubernetes", count=05) #auto retweet when match is found with a specific topic my_bot.auto_rt("devops", count=2) #auto follow the followers my_bot.auto_follow_followers()
#!/usr/bin/env python2 # -*- coding: utf-8 -*- # #Author: Ray Okaah #This prunes / auto un follows every user who is not following back. from TwitterFollowBot import TwitterBot #Below, Raybotlist is Depreciated #Raybotlist = "m1.txt,m2.txt,m3.txt,m4.txt,m5.txt,m6.txt,m7.txt,m8.txt,,m9.txt,m10.txt,m11.txt,m12.txt,m13.txt,m14.txt,m15.txt,m16.txt,m17.txt,m18.txt,m19.txt,m20.txt,m21.txt,m22.txt,m23.txt,m24.txt,m25.txt,m26.txt,m27.txt,m28.txt,m29.txt,m30.txt,m31.txt,m32.txt,m33.txt,m34.txt,m35.txt,m36.txt,m37.txt,m38.txt,m39.txt,m40.txt,m41.txt,m42.txt,m43.txt,m44.txt,m45.txt,m46.txt,m47.txt,m48.txt,m49.txt,m50.txt" #workingdir = os.getcwd() #Raybotdir = os.listdir(workingdir+"/AllBotConfig/") Raybotdir = os.listdir("https://guarded-chamber-8525.herokuapp.com/AllBotConfig/") for ig in Raybotdir: my_bot = TwitterBot("/AllBotConfig/"+ig) my_bot.auto_unfollow_nonfollowers() if __name__ == '__main__': bot = PruneRun.py() bot.run()
from TwitterFollowBot import TwitterBot my_bot = TwitterBot() my_bot.send_tweet("Hello world!")
from TwitterFollowBot import TwitterBot from bs4 import BeautifulSoup import time, random while True: my_bot = TwitterBot()#Инициализирую бота def getQoute(): soup = BeautifulSoup(open('test1.html'), 'lxml') for rendom_aph in soup.find_all('div',{'class':'rendom_aph'}): print((str(rendom_aph.text))) if len(rendom_aph.text) >=132: #Проверка длины отправки сообщения Если больше 133 то повторно выполнить парсинг time.sleep(10) getQoute() else: return rendom_aph.text a = getQoute() #dict = ['Qoute', 'DatQt', 'FunDy', 'Mind'] #Словарь хештегов my_bot.send_tweet(a + '#Follow' )#Бот шлет сообщение time.sleep(3600)
#import nose #import unittest import numpy as np import pandas as pd from pandas import * from PIL import Image from pprint import pprint #import pyttsx import shutil import getpass import random from TwitterFollowBot import TwitterBot # In[2]: my_bot = TwitterBot() # In[3]: hosnam = getpass.getuser() # In[4]: gtsdrndir = ('/home/' + hosnam + '/getsdrawndotcom/') # In[5]: gtsdrndir # In[6]:
#followfolloersof #python run_bot.py twitter_handle import sys from TwitterFollowBot import TwitterBot my_bot = TwitterBot() my_bot.sync_follows() account = sys.argv[1:][0] print "About to start following followers of " + account my_bot.auto_follow_followers_of_user(account, count=1000)
from TwitterFollowBot import TwitterBot my_bot = TwitterBot() my_bot.auto_follow_followers_of_user("bandsintown", count=10) my_bot.auto_follow_followers_of_user("songkick", count=10) my_bot.auto_follow_followers_of_user("thefader", count=10) my_bot.auto_follow_followers_of_user("billboard", count=10) my_bot.auto_follow_followers_of_user("pitchfork", count=10) my_bot.auto_follow_followers_of_user("noiseymusic", count=10)
from TwitterFollowBot import TwitterBot '''Use default config.txt file in the same directory.''' my_bot = TwitterBot() '''Create cache files in the current directory.''' my_bot.sync_follows() '''Autofav a tweet with the user's keyword. Count set at 1000 for testing.''' my_bot.auto_fav("The phrase string to favorite", count=1000)
def retweet(event): my_bot = TwitterBot() hashtag = '#' + event['hashtag'] # autoretweets the 5(count) latest tweets that matches the hashtag my_bot.auto_rt(hashtag, count=5)
from TwitterFollowBot import TwitterBot my_bot = TwitterBot("mcon.txt") my_bot.sync_follows()
logger.info("Fetching Complete w/ no errors!") def syncCronListener(event): if event.exception: logger.error("syncCronListener: %s" % repr(event.exception)) else: logger.info("Syncing Complete w/ no errors!") if __name__ == "__main__": #start logger.info("[+]Starting MoombahBot") #init scheduler sched = BackgroundScheduler() #init bot moombahBot = TwitterBot(config_file=apiConfFile, logger=logger) #Sync once daily sched.add_job(lambda: moombahBot.sync_follows(), 'interval', hours=23, replace_existing=True) sched.add_listener(fetchCronListener, events.EVENT_JOB_EXECUTED | events.EVENT_JOB_ERROR) logger.debug('Account sync cronjob added') #Fetch at interval sched.add_job(lambda: fetch(moombahBot), 'interval', minutes=fetchIntervalMinutes, replace_existing=True) sched.add_listener(syncCronListener, events.EVENT_JOB_EXECUTED | events.EVENT_JOB_ERROR) logger.debug('Fetch cronjob added') #start sched cron sched.start() #Running
from TwitterFollowBot import TwitterBot import random my_bot = TwitterBot() #my_bot.sync_follows() file_ = open('TwitterBot/tanach.txt') randomLine = (random.choice(list(file_))) my_bot.send_tweet(randomLine)
if os.path.exists('twitterLogo.txt'): with open('twitterLogo.txt', 'r') as fin: print Fore.BLUE + Style.BRIGHT + fin.read() #Print BotTweet print "\n" if os.path.exists('titleLogo.txt'): with open('titleLogo.txt', 'r') as fin: print Fore.BLUE + Style.BRIGHT + fin.read() print "Copyright " + u"\u00a9" + " 2015 Brandon Jabr.\n" #TO-DO: CHECK CONFIG FILE #Load environment TwitterAPI = TwitterBot(config_file_name) username = TwitterAPI.BOT_CONFIG["TWITTER_HANDLE"] print Style.BRIGHT + "\nCurrent User: "******"" amount = 15 following = list(TwitterAPI.get_follows_list()) auto_follow = False #Collect user input
from TwitterFollowBot import TwitterBot import sys import random import time #decale le start du bot if (len(sys.argv) < 3 or sys.argv[2] != "nowait"): time.sleep(random.random() * 500 + 1) #get arguments et lance bot my_bot = TwitterBot() print(sys.argv[1]) #gestion du cache my_bot = TwitterBot() my_bot.sync_follows() #autofav something my_bot.auto_fav(sys.argv[1], random.randint(1, 8))
from TwitterFollowBot import TwitterBot print("Initializing TwitterBot...") my_bot = TwitterBot() print("Synchronizing follows...") my_bot.sync_follows() print("Complete!")
def tweet(msg): my_bot = TwitterBot(config_file=os.path.join(script_dir(), "config.txt")) my_bot.send_tweet(msg)
def retweet(): my_bot = TwitterBot() my_bot.auto_rt("caa", count=10)
from TwitterFollowBot import TwitterBot my_bot = TwitterBot() my_bot.auto_fav("beyond wonderland") my_bot.auto_fav("sxsw") my_bot.auto_fav("electric daisy carnival") my_bot.auto_fav("lights all night") my_bot.auto_fav("mad decent block party") my_bot.auto_fav("moogfest") my_bot.auto_fav("tomorrowland") my_bot.auto_fav("tomorrowworld") my_bot.auto_fav("ultra festival") my_bot.auto_fav("ultra miami") my_bot.auto_fav("electric zoo") my_bot.auto_fav("life in color") my_bot.auto_fav("#lic") my_bot.auto_fav("edc vegas") my_bot.auto_fav("electric forest") my_bot.auto_fav("euphoria festival") my_bot.auto_fav("hard summer") my_bot.auto_fav("hard day of the dead") my_bot.auto_fav("lightning in a bottle") my_bot.auto_fav("mad decent boat party") my_bot.auto_fav("lights all night") my_bot.auto_fav("#lan2015")
from TwitterFollowBot import TwitterBot import sys import random import time #decale le start du bot if (len(sys.argv) < 3 or sys.argv[2] != "nowait"): time.sleep(random.random() * 30 + 1) #gestion du cache my_bot = TwitterBot() my_bot.sync_follows() #decale le start du bot if (len(sys.argv) < 3 or sys.argv[2] != "nowait"): time.sleep(random.random() * 50 + 1) #FollowBackUSer my_bot.auto_follow_followers_of_user(sys.argv[1])
####Post from TwitterFollowBot import TwitterBot my_bot = TwitterBot() my_bot.send_tweet("Teste") #### from TwitterFollowBot import TwitterBot my_bot = TwitterBot() from TwitterFollowBot import TwitterBot my_bot = TwitterBot("config.txt") ##from TwitterFollowBot import TwitterBot ## ##my_bot = TwitterBot() ##my_bot.auto_follow("") ## ##from TwitterFollowBot import TwitterBot ## ##my_bot = TwitterBot() ##my_bot.auto_follow("") ## ##from TwitterFollowBot import TwitterBot ## ##my_bot = TwitterBot() ##my_bot.auto_follow("", count=100)
#retweetfollowuserwithphrase #python run_bot3.py count phrase1 #hashtag1 import sys from TwitterFollowBot import TwitterBot my_bot = TwitterBot() count = sys.argv[1:][0] phrases = sys.argv[2:] for num in range(0,int(count)): for phrase in phrases: print "RTing the tweet with phrase " + phrase + " and following the user" my_bot.auto_rt_and_follow(phrase, count=1)
from TwitterFollowBot import TwitterBot my_bot = TwitterBot("mcon.txt") my_bot.auto_follow_followers_of_user("TheHiddenWorId", count=25)
from TwitterFollowBot import TwitterBot my_bot = TwitterBot() #my_bot.sync_follows() my_bot.send_tweet("testing 1, 2, 3...")
from TwitterFollowBot import TwitterBot my_bot = TwitterBot() #my_bot.sync_follows() phrase = "Jewish" count = 100 result_type = "recent" result = my_bot.search_tweets(phrase, count, result_type) for tweet in result["statuses"]: print( tweet["user"]["screen_name"] ) #my_bot.send_tweet(markov.generate_markov_text())
from TwitterFollowBot import TwitterBot my_bot = TwitterBot() my_bot.auto_fav("bonnaroo") my_bot.auto_fav("coachella") my_bot.auto_fav("austin city limits") my_bot.auto_fav("governors ball") my_bot.auto_fav("digital dreams") my_bot.auto_fav("outside lands") my_bot.auto_fav("voodoo fest") my_bot.auto_fav("firefly festival") my_bot.auto_fav("hangout festival") my_bot.auto_fav("jazz fest") my_bot.auto_fav("sxsw") my_bot.auto_fav("wakarusa") my_bot.auto_fav("wanderlust festival")
from TwitterFollowBot import TwitterBot my_bot = TwitterBot() my_bot.auto_fav("kanye") my_bot.auto_fav("drake") my_bot.auto_fav("rave") my_bot.auto_fav("festival") my_bot.auto_fav("#festival") my_bot.auto_fav("#concert") my_bot.auto_fav("concert") my_bot.auto_fav("#plur") my_bot.auto_fav("#onedirection") my_bot.auto_fav("#1d") my_bot.auto_fav("#justinbieber") my_bot.auto_fav("one direction") my_bot.auto_fav("justin bieber") my_bot.auto_fav("dj") my_bot.auto_fav("raver nation") my_bot.auto_fav("rave babes") my_bot.auto_fav("raver") my_bot.auto_fav("#raver") my_bot.auto_fav("#trap") my_bot.auto_fav("#hardstyle") my_bot.auto_fav("#plur") my_bot.auto_fav("house music") my_bot.auto_fav("deep house") my_bot.auto_fav("trap music") my_bot.auto_fav("#nowplaying") my_bot.auto_fav("#np") my_bot.auto_fav("mixtape") my_bot.auto_fav("ovo radio")
import tweepy from TwitterFollowBot import TwitterBot my_bot = TwitterBot() keywords = [line.rstrip('\n') for line in open('brands.txt')] follow = [line.rstrip('\n') for line in open('Followthese.txt')] charities = [line.rstrip('\n') for line in open('charities.txt')] my_bot.auto_fav("charity", count=1) var = 1 while var == 1: keywordcount = 0 while keywordcount < len(keywords): for keyword in keywords: my_bot.auto_rt(keyword, count=1) keywordcount += 1 followcount = 0 while followcount < len(follow): for user in follow: my_bot.auto_follow_followers_of_user(user, count=1) followcount += 1 charitycount = 0 while charitycount < len(charities): for charity in charities: my_bot.send_tweet("Dont forget to help out people at" + charity) charitycount += 1 print("Should start from top") print("Good bye :(")
from TwitterFollowBot import TwitterBot my_bot = TwitterBot() my_bot.sync_follows() my_bot.auto_follow_followers()
# coding:utf-8 from TwitterFollowBot import TwitterBot my_bot = TwitterBot() my_bot.sync_follows() my_bot.auto_fav("機械学習", count=5) my_bot.auto_fav("人工知能", count=5) my_bot.auto_fav("エンジニア", count=5) my_bot.auto_fav("ブロックチェーン", count=5) my_bot.auto_fav("スマートコントラクト", count=5) my_bot.auto_fav("落合 陽一", count=5) my_bot.auto_fav("MIT media lab", count=5) my_bot.auto_fav("研究 留学", count=5) my_bot.auto_fav("tensorflow", count=5) my_bot.auto_fav("deeplearn.js", count=5) my_bot.auto_fav("NetLogo", count=5) my_bot.auto_fav("smart city", count=5) my_bot.auto_fav("connpass", count=5) my_bot.auto_fav("早稲田", count=5) my_bot.auto_fav("慶応", count=5) my_bot.auto_fav("東京大学", count=5) my_bot.auto_fav("松尾研", count=5) my_bot.auto_fav("微積", count=5) my_bot.auto_fav("線形代数", count=5) my_bot.auto_fav("ロンドン 留学", count=5) my_bot.auto_fav("大学 研究", count=5) my_bot.auto_fav("京大 留学", count=5) my_bot.auto_fav("音楽 都市", count=5) my_bot.auto_fav("在住", count=5) my_bot.auto_fav("ロンドン 音楽", count=5) my_bot.auto_fav("ロンドン 在住", count=5)
"r") as already_txt: for non_follower in already_txt: alr_follow.append(int(non_follower)) i = 0 while i < len(alr_follow): if (alr_follow[i] in followers_a): del alr_follow[i] i += 1 with open('/home/scripts/twitter/already-followed.txt', "w") as out_file: for non_follower in alr_follow: out_file.write("%s\n" % (non_follower)) config = 'config.txt' my_bot = TwitterBot(config) stars = '*' * 10 if not os.path.isfile('followers.txt'): print('%sPhase of follow followers%s' % (stars, stars)) print(time.asctime(), '\n') my_bot.sync_follows() my_bot.auto_follow_followers() print('%sWaiting 6-7h%s' % (stars, stars)) print(time.asctime(), '\n') time.sleep(random.randint(6 * 60 * 60, 7 * 60 * 60)) while True: following_bot = my_bot.get_follows_list()
from TwitterFollowBot import TwitterBot my_bot = TwitterBot() my_bot.auto_fav("teaching a robot") my_bot.auto_fav("helping a robot") my_bot.auto_fav("producing a robot") my_bot.auto_fav("doing the robot") my_bot.auto_fav("robot on television") my_bot.auto_fav("robot television")
import sys import os import argparse from TwitterFollowBot import TwitterBot my_bot = TwitterBot("config-sendx.txt") ap = argparse.ArgumentParser(description='Twitter growth strategies') dir_path = os.path.dirname(os.path.realpath(__file__)) def follow_follower_of_account(account, _count): print "About to start following followers of " + account my_bot.auto_follow_followers_of_user(account, count=_count) def follow_user_like_tweet(file_name, count): file_path = dir_path + "/data/" + file_name print "Reading phrases from file " + file_path with open(file_path) as f: for num in range(0, int(count)): for phrase in f: print "Following the user and liking the tweet with phrase " + phrase my_bot.auto_fav_and_follow(phrase, count) def follow_user_retweet(file_name, count): file_path = dir_path + "/data/" + file_name
#import unittest import numpy as np import pandas as pd from pandas import * from PIL import Image from pprint import pprint #import pyttsx import shutil import getpass import random from TwitterFollowBot import TwitterBot # In[2]: my_bot = TwitterBot() # In[3]: hosnam = getpass.getuser() # In[4]: gtsdrndir = ('/home/' + hosnam + '/getsdrawndotcom/') # In[5]: gtsdrndir
import datetime from TwitterFollowBot import TwitterBot my_bot = TwitterBot() my_bot.sync_follows() my_bot.auto_unfollow_nonfollowers()
from TwitterFollowBot import TwitterBot my_bot = TwitterBot() my_bot.auto_follow("Retweet + Likes", count=1) my_bot.auto_rt("Retweet + Like", count=1) my_bot.auto_fav("Retweet + Like", count=1)
from TwitterFollowBot import TwitterBot my_bot = TwitterBot() my_bot.auto_unfollow_nonfollowers()
from TwitterFollowBot import TwitterBot import markovgen my_bot = TwitterBot() #my_bot.sync_follows() file_ = open('TwitterBot/tanach.txt') markov = markovgen.Markov(file_) my_bot.send_tweet(markov.generate_markov_text())
from TwitterFollowBot import TwitterBot print("Initializing TwitterBot...") my_bot = TwitterBot() #print("Synchronizing follows...") #my_bot.sync_follows() print("Auto-unfollowing the non-followers (or: PURGE THE NONBELIEVERS!!!)") my_bot.auto_unfollow_nonfollowers() print("Complete!")
from TwitterFollowBot import TwitterBot import sys import random import time #decale le start du bot if (len(sys.argv) < 3 or sys.argv[1] != "nowait"): time.sleep(random.random() * 50 + 1) #get arguments et lance bot #my_bot = TwitterBot() #print(sys.argv[1]) #gestion du cache my_bot = TwitterBot() my_bot.sync_follows() #decale le start du bot if (len(sys.argv) < 3 or sys.argv[1] != "nowait"): time.sleep(random.random() * 500 + 1) #Unfollow auto #my_bot.auto_unfollow_nonfollowers() #mute everymote my_bot.auto_mute_following() #autoRT something #my_bot.auto_rt(sys.argv[1], random.randint(1,3))
from TwitterFollowBot import TwitterBot my_bot = TwitterBot() my_bot.auto_follow("business")
#!/usr/bin/env python from TwitterFollowBot import TwitterBot import facebook_bot import time,sys,re if len(sys.argv) != 3: print('usage: ./mr_vtcsec <twitter-config> <fb-access-token-file>') sys.exit(1) tbot = TwitterBot(sys.argv[1]) fbot = facebook_bot.FacebookBot(sys.argv[2],'203269536364770') # public id of vtcsec fb page def build_link(t,author): return 'https://twitter.com/'+author+'/status/'+str(t['id']) def build_fb_post(t): text = t['retweeted_status']['text'] print text author = re.search(r'@(.+?):',t['text']).groups()[0] src = build_link(t,author) pic = None if 'entities' in t: if len(t['entities']['urls']): src = t['entities']['urls'][0]['expanded_url'] if 'media' in t['entities'] and len(t['entities']['media']): med = t['entities']['media'][0]