当前位置: 首页>>代码示例>>Python>>正文


Python Twython.lookupUser方法代码示例

本文整理汇总了Python中twython.Twython.lookupUser方法的典型用法代码示例。如果您正苦于以下问题:Python Twython.lookupUser方法的具体用法?Python Twython.lookupUser怎么用?Python Twython.lookupUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twython.Twython的用法示例。


在下文中一共展示了Twython.lookupUser方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: userFriends

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import lookupUser [as 别名]
def userFriends(user=''):
	twitter = Twython()
	friends = twitter.getFriendsIDs(screen_name=user)["ids"]
	friend_list=''
	friends_bio=''
	i=0
	for friend in friends:
		friend_list += str(friend) + ','
		if((i+1)%100==0):
			aux = twitter.lookupUser(user_id=friend_list[:-1])
			for x in aux:
				try:
					friends_bio += x['description'].encode('ascii', 'replace')
				except:
					pass
			print friends_bio
			friend_list=''
			sleep(10)
		i+=1
	#for i in range(len(friends)):
	#	friend_list = friend_list + str(friends[i]) + ','
	#	print i, friend_list
	#	if((i+1)%100==0):
	#		aux = twitter.lookupUser(user_id=friend_list[:-1])
	#		print friend_list
	#		for x in range(100):
	#			print x
	#			friends_bio += aux[x]['description'].encode('ascii', 'replace')
	#			friends_bio += ' '
	#		sleep(5)
	#	friend_list=''
	#lookup = twitter.lookupUser(user_id=friend_list)
	return friends_bio
开发者ID:alvarofaundez,项目名称:SmartboxTv,代码行数:35,代码来源:server.py

示例2: friend_favorites

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import lookupUser [as 别名]
def friend_favorites(request, friend_id):
    user = request.user.twitterprofile
    twitter = Twython(
        twitter_token=settings.TWITTER_KEY,
        twitter_secret=settings.TWITTER_SECRET,
        oauth_token=user.oauth_token,
        oauth_token_secret=user.oauth_secret,
    )
    friend = twitter.lookupUser(user_id=friend_id)
    favorites = twitter.getFavorites(user_id=friend_id, count=200)

    return render_to_response("favorites.html", {"favorites": favorites, "friend": friend})
开发者ID:benregn,项目名称:twitter_favorites,代码行数:14,代码来源:views.py

示例3: friends

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import lookupUser [as 别名]
def friends(request):
    """
        An example view with Twython/OAuth hooks/calls to fetch data about the user
        in question. Pretty self explanatory if you read through it...
    """
    user = request.user.twitterprofile
    twitter = Twython(
        twitter_token=settings.TWITTER_KEY,
        twitter_secret=settings.TWITTER_SECRET,
        oauth_token=user.oauth_token,
        oauth_token_secret=user.oauth_secret,
    )
    # user_tweets = twitter.getHomeTimeline()
    user_friends_ids = twitter.getFriendsIDs()["ids"]
    friends_details = twitter.lookupUser(user_id=user_friends_ids)

    return render_to_response("friends.html", {"friends": friends_details})
开发者ID:benregn,项目名称:twitter_favorites,代码行数:19,代码来源:views.py

示例4: gnius

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import lookupUser [as 别名]
def gnius(user='rafalopezpo'):
	nltk.data.load('tokenizers/punkt/spanish.pickle')
	stops_es=stopwords.words('spanish')
	stops_en=stopwords.words('english')

	twitter = Twython()
	#user=raw_input('user: ')
	print '\nUser Description\n\n'
	lookup = twitter.lookupUser(screen_name=user)
	lookup = lookup[0]['description'].encode('ascii', 'replace')
	lookup_t = nltk.word_tokenize(lookup)
	stops_custom = ['http']
	cleaned_lookup = [word.lower() for word in lookup_t if word not in stops_es and word not in stops_custom and word not in stops_en and word.isalpha() and len(word)>2]
	print cleaned_lookup
	print '\nUser Timeline\n\n'
	# We won't authenticate for this, but sometimes it's necessary
	user_timeline = twitter.getUserTimeline(screen_name=user, count='200')
	all_tweets=''
	for tweet in user_timeline:
		text = tweet['text'].encode('ascii', 'replace')
		all_tweets +=' ' + text 
	#print '\nTexto\n\n%s' % (all_tweets)
	all_tweets_t = nltk.word_tokenize(all_tweets)
	cleaned_tweets = [word.lower() for word in all_tweets_t if word not in stops_es and word not in stops_custom and word not in stops_en and word.isalpha() and len(word)>2]
	print '\nTokens\n'
	print cleaned_tweets
	c = Counter(cleaned_tweets)
	print '\nCommon terms\n'
	t=c.most_common(5)
	d={}
	for x in t:
		d[]
	j=json.dumps(d)
	print j
	#t=nltk.Text(cleaned_tweets)
	#t=({'user':user})
	return j
开发者ID:alvarofaundez,项目名称:SmartboxTv,代码行数:39,代码来源:nlp.py

示例5: userBio

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import lookupUser [as 别名]
def userBio(user=''):
	twitter = Twython()
	lookup = twitter.lookupUser(screen_name=user)
	lookup = lookup[0]['description'].encode('ascii', 'replace')#Extraer texto de Bio
	return tokenize(lookup)
开发者ID:alvarofaundez,项目名称:SmartboxTv,代码行数:7,代码来源:server.py

示例6: getScreenNameFromUserId

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import lookupUser [as 别名]
	def getScreenNameFromUserId (self, userId):
		#Returns the screen name for an specific user id
		twitter = Twython()
		userData =  twitter.lookupUser(user_id = userId)
		print "Screen Name %s for userId %s" %(userData[0]['screen_name'], userId);
		return userData[0]['screen_name']
开发者ID:amirmc,项目名称:signpost,代码行数:8,代码来源:twitterChecker.py

示例7: getUserLocationFromScreenName

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import lookupUser [as 别名]
	def getUserLocationFromScreenName (self, screenName):
		#Returns the user location for a given user
		twitter = Twython()
		userData =  twitter.lookupUser(screen_name = screenName)
		print "Location for %s -> %s" % ( screenName, userData[0]['location'])
		return userData[0]['location']
开发者ID:amirmc,项目名称:signpost,代码行数:8,代码来源:twitterChecker.py

示例8: getUserLocationFromId

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import lookupUser [as 别名]
	def getUserLocationFromId (self, userId):
		#Returns the user location for a given user
		twitter = Twython()
		userData =  twitter.lookupUser(user_id = userId)
		print "Location for %s -> %s" % ( userId, userData[0]['location'])
		return userData[0]['location']
开发者ID:amirmc,项目名称:signpost,代码行数:8,代码来源:twitterChecker.py

示例9: getUserName

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import lookupUser [as 别名]
	def getUserName (self, userId):
		#Returns the real name for a given userId
		twitter = Twython()
		userData =  twitter.lookupUser(user_id = userId)
		print "Real name for %s (aka %s) is %s" %(userId, userData[0]['screen_name'], userData[0]['name'])
		return userData[0]['name']
开发者ID:amirmc,项目名称:signpost,代码行数:8,代码来源:twitterChecker.py

示例10: getUserIdFromScreenName

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import lookupUser [as 别名]
	def getUserIdFromScreenName (self, screenName):
		#Returns the user Id for a given screen name
		twitter = Twython()
		userData =  twitter.lookupUser(screen_name = screenName)
		print "User ID %s for user %s" %(userData[0]['id'], screenName)
		return userData[0]['id']
开发者ID:amirmc,项目名称:signpost,代码行数:8,代码来源:twitterChecker.py


注:本文中的twython.Twython.lookupUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。