本文整理汇总了Python中Auth.get_authentication方法的典型用法代码示例。如果您正苦于以下问题:Python Auth.get_authentication方法的具体用法?Python Auth.get_authentication怎么用?Python Auth.get_authentication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auth
的用法示例。
在下文中一共展示了Auth.get_authentication方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fetch_data
# 需要导入模块: import Auth [as 别名]
# 或者: from Auth import get_authentication [as 别名]
def fetch_data(screen_name=None,ids=[]):
api=Auth.get_authentication(screen_name=screen_name)
list_pairs={}
out_path='/DataFiles/Users/pairs'#
if os.path.exists(out_path):
with open(out_path,'rb') as handle:
list_pairs=cPickle.loads(handle.read())
if len(list_pairs)>0:
extract = lambda data, sampled_data: dict(zip(data, map(sampled_data.get, data)))
list_pairs=extract(ids,list_pairs)
current_time=datetime.datetime.now()
for ID in ids:
try:
usr=api.GetUser(ID)
nFollows=usr.GetFollowersCount()
nFriends=usr.GetFriendsCount()
nStatus=usr.GetStatusesCount()
if nFollows==None or nFriends==None or nStatus==None:
continue
if list_pairs.has_key(ID):
if list_pairs[ID]!=None:
list_pairs[ID].append((nFollows,nFriends,nStatus,current_time))
else:
list_pairs[ID]=[(nFollows,nFriends,nStatus,current_time)]
except twitter.TwitterError, ex:
print ex.message
if "Clients may not make more than 350 requests per hour" in ex.message:
print screen_name
break
else:
continue
示例2: check_in
# 需要导入模块: import Auth [as 别名]
# 或者: from Auth import get_authentication [as 别名]
def check_in(in_path="/DataFiles/sub_paricipants.txt",out_path="/DataFiles/participants/"):
screen_names=['auth_user1','auth_user2']
checked_participants_file='/DataFiles/participants/checked.txt'
notauthorized_participants_file='/DataFiles/participants/notAuthorized.txt'
while len(screen_names)>0:
screen_name=screen_names.pop()
print screen_name
participants=return_participants(file_path=in_path)
#print len(participants)
if os.path.exists(checked_participants_file):
with open(checked_participants_file,'rb') as handle:
checked_partice=cpik.loads(handle.read())
participants=participants-checked_partice
if os.path.exists(notauthorized_participants_file):
with open(notauthorized_participants_file,'rb') as handle:
checked_partice=cpik.loads(handle.read())
participants=participants-checked_partice
if len(participants)==0:
if os.path.exists (checked_participants_file):
os.remove(checked_participants_file)
if os.path.exists (notauthorized_participants_file):
os.remove(notauthorized_participants_file)
print 'successfully finittto! beginning next round!'
api=Auth.get_authentication(screen_name=screen_name)
status=recored_participants_graphs(api=api,participants=participants)
示例3: scrape
# 需要导入模块: import Auth [as 别名]
# 或者: from Auth import get_authentication [as 别名]
def scrape(partic_file='DataFiles/paricipants.txt'):
participants=return_participants(file_path=partic_file)
my_screenname='Auth_user'
out_path='DataFiles/Tweets/'
api=Auth.get_authentication(screen_name=my_screenname)
max_twt_count=10
count=5
bb=0
for part in participants:
counter=0
tweets=[]
max_twt_id=None
try:
user_id=int(part)
user=api.GetUser(user_id)
tweets_count=user.statuses_count
except twitter.TwitterError, ex:
print ex.message
continue
threshold=min([max_twt_count,tweets_count])
while counter<threshold:
try:
temp=api.GetUserTimeline(user_id=user_id,max_id=max_twt_id,include_entities=True,count=count,include_rts=True)
counter+=len(temp)
tweets+=temp
max_twt_id=return_maxID(tweets=temp)
except twitter.TwitterError , ex:
print ex.message
break
if max_twt_id==None:
break
示例4: len
# 需要导入模块: import Auth [as 别名]
# 或者: from Auth import get_authentication [as 别名]
tweet_count=0
if user.has_key('statuses_count'):
tweet_count=user['statuses_count']
if (num_followers<down_followers or num_followers>up_followers or r >= ratio or tweet_date<deadline or tweet_count<=0):
return False
return True
if __name__ == '__main__':
tempfile.tempdir='/local/scratch/mh717'
if len(sys.argv)>1:
my_screen=sys.argv[1]
else:
my_screen="data1_surgeon"
print '******Following***********'+str(datetime.datetime.today())+'*****************'+my_screen
toss=random.random()
if toss<0.9:
api=Auth.get_authentication(my_screen)
#repository=['UNICEF','VolunteerGlobal','VolunteerCal','VolunteerTO','VolunteerMatch','AmericanCancer','AllHands','VolunteeringEng','MindCharity','AskMen','UN_Women','David_Cameron','googleresearch','BradPittsPage','BillGates','BarackObama','facebook','CommunityCare','hootsuite','mashable','TheNextWeb','Donnaantoniadis','NielsenWire','adidasoriginals','iTunesMusic','UniversalMusica','HuffPostWomen','womenoffaith']
repository=['BBCBreaking','cnnbrk','rihanna','Olympics','socialmedia2day','VolunteerCanada','ChampionsLeague','QueenLizII','kate_middleton','DukeCambridgeUK']
max_friend=int(round(15+(26-15)*random.random()))
n_followed=0
while n_followed<max_friend and len(repository)>0:
rnd_index=int(round(random.random()*(len(repository)-1)))
n_followed=follow_people(repository[rnd_index],max_friend,api=api)
if n_followed<max_friend:
repository.remove(repository[rnd_index])
else:
print 'skipped!'
print '***************** END *******' +my_screen +'*****************'