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


Python Twython.search_users方法代码示例

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


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

示例1: spiderInfo

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import search_users [as 别名]
    def spiderInfo(self, name, limit):
        index = 0
        c = 0
        result_info  = []

        if limit == 0:
            limit = 5
        t = Twython(app_key = "",
            app_secret = "",
            oauth_token = "",
            oauth_token_secret = "")

        while c<limit:
            res = t.search_users(q=name, page=index, count=5)
            length = len(res)
            for content in res:
                single_data={}
                single_data["thumb_url"] = content["profile_image_url"]
                single_data["text"] = content["screen_name"]
                single_data["author_name"] = content["name"]
                single_data["text"] = "\nLocation:      " + json.dumps(content["location"]) +\
                                ", Philippines\n\nLanguage:      " + json.dumps(content["lang"]) +\
                                "\n\nFriends Count: " + json.dumps(content["friends_count"]) +\
                                "\n\nTime Zone:     " + json.dumps(content["time_zone"]) +\
                                "\n\nDescription:   " + json.dumps(content["description"])
                result_info.append(single_data)
                c+=1
                if c==limit:
                    return result_info
            if length<5:
                return result_info
            index+=1
        return result_info
开发者ID:lovexi,项目名称:CodingMonkey-Bot-Python-version,代码行数:35,代码来源:_twitter.py

示例2: spiderInfo

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import search_users [as 别名]
def spiderInfo(name,limit):
    resultInfo=[]
    index = 0
    c=0
    if limit==0:
        limit=5
    t = Twython(app_key='6JGtb2KvWbCNiFL2yxM4tsf3X', 
        app_secret='8PKemZoO4iM5JMfDxxCdpstPjbJBUqqVWwTkZlULoMqJULSO5V',
        oauth_token='704548355-t91wJGga1YdvwimCgoOTmaDE9wU3gpK4SojmATwz',
        oauth_token_secret='EdDeMHy5cvE2SYhAE2bRsartr4iAkYMo34TZzCj2HeVaj')
    
    while c<limit:
        res=t.search_users(q=name,page=index,count=5)
        length=len(res)
        for content in res:
            dict={}
            dict['profile_image_url']=encodeImage(content['profile_image_url'])
            dict['location']=content['location']
            dict['name']= content['name']
            dict['screen_name']=content['screen_name']
#            print dict['name']
            dict['lang']=content['lang']
            dict['friends_count']=content['friends_count']
            dict['time_zone']= content['time_zone']
            dict['description']=content['description']
            dict['favourites_count'] =content['favourites_count']
            dict['followers_count'] =content['followers_count']
            resultInfo.append(dict)
            c+=1
            if c==limit:
                return resultInfo
        if length<5:
            return resultInfo
        index+=1
    return resultInfo
开发者ID:AU-Hackathon-2016,项目名称:twitter,代码行数:37,代码来源:grab.py

示例3: twSearch2

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import search_users [as 别名]
def twSearch2(target, user):
    twitter = Twython(CUSTOMER_KEY, CUSTOMER_SECRET,
                user.token, user.secret)

    # ACCESS_TOKEN = twitter.obtain_access_token()
    # twitter = Twython( APP_KEY, access_token=ACCESS_TOKEN)
    result = {'user': user, 'results': twitter.search_users(q=target) }
    return result
开发者ID:ratin0x,项目名称:TRP,代码行数:10,代码来源:twithandler.py

示例4: twSearch

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import search_users [as 别名]
def twSearch(target, oauth_verifier, token, secret):
    # twitter = Twython( APP_KEY, APP_SECRET)
    # auth = twitter.get_authentication_tokens(callback_url='http://81.174.167.24/tr/verify')
    # OAUTH_TOKEN = auth['oauth_token']
    # OAUTH_SECRET = auth['oauth_token_secret']
    # HttpResponseRedirect(auth['auth_url'])

    # oauth_verifier = r['oauth_verifier']

    # oauth_verifier = r.text
    global CUSTOMER_KEY
    global CUSTOMER_SECRET

    twitter = Twython(CUSTOMER_KEY, CUSTOMER_SECRET,
                  token, secret)

    final_step = twitter.get_authorized_tokens(oauth_verifier)

    OAUTH_TOKEN = final_step['oauth_token']
    OAUTH_SECRET = final_step['oauth_token_secret']
    name = final_step['screen_name']
    twid = final_step['user_id']

    allusers = list(User.objects.values())

    user = User.objects.create(name=str(name), twid=twid, token=OAUTH_TOKEN, secret=OAUTH_SECRET)

    # user.save()

    twitter = Twython(CUSTOMER_KEY, CUSTOMER_SECRET,
                  OAUTH_TOKEN, OAUTH_SECRET)

    # ACCESS_TOKEN = twitter.obtain_access_token()
    # twitter = Twython( APP_KEY, access_token=ACCESS_TOKEN)
    result = {'user': user, 'results': twitter.search_users(q=target) }
    return result
开发者ID:ratin0x,项目名称:TRP,代码行数:38,代码来源:twithandler.py

示例5: TwythonAPITestCase

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import search_users [as 别名]

#.........这里部分代码省略.........
        '''Test updating profile succeeds'''
        self.api.update_profile(include_entities='true')

    def test_update_profile_colors(self):
        '''Test updating profile colors succeeds'''
        self.api.update_profile_colors(profile_background_color='3D3D3D')

    def test_list_blocks(self):
        '''Test listing users who are blocked by the authenticated user
        succeeds'''
        self.api.list_blocks()

    def test_list_block_ids(self):
        '''Test listing user ids who are blocked by the authenticated user
        succeeds'''
        self.api.list_block_ids()

    def test_create_block(self):
        '''Test blocking a user succeeds'''
        self.api.create_block(screen_name='justinbieber')

    def test_destroy_block(self):
        '''Test unblocking a user succeeds'''
        self.api.destroy_block(screen_name='justinbieber')

    def test_lookup_user(self):
        '''Test listing a number of user objects succeeds'''
        self.api.lookup_user(screen_name='twitter,justinbieber')

    def test_show_user(self):
        '''Test showing one user works'''
        self.api.show_user(screen_name='twitter')

    def test_search_users(self):
        '''Test that searching for users succeeds'''
        self.api.search_users(q='Twitter API')

    def test_get_contributees(self):
        '''Test returning list of accounts the specified user can
        contribute to succeeds'''
        self.api.get_contributees(screen_name='TechCrunch')

    def test_get_contributors(self):
        '''Test returning list of accounts that contribute to the
        authenticated user fails because we are not a Contributor account'''
        self.assertRaises(TwythonError, self.api.get_contributors,
                          screen_name=screen_name)

    def test_remove_profile_banner(self):
        '''Test removing profile banner succeeds'''
        self.api.remove_profile_banner()

    def test_get_profile_banner_sizes(self):
        '''Test getting list of profile banner sizes fails because
        we have not uploaded a profile banner'''
        self.assertRaises(TwythonError, self.api.get_profile_banner_sizes)

    # Suggested Users
    def test_get_user_suggestions_by_slug(self):
        '''Test getting user suggestions by slug succeeds'''
        self.api.get_user_suggestions_by_slug(slug='twitter')

    def test_get_user_suggestions(self):
        '''Test getting user suggestions succeeds'''
        self.api.get_user_suggestions()
开发者ID:chrisbol,项目名称:twython,代码行数:69,代码来源:test_twython.py

示例6: TwythonAPITestCase

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import search_users [as 别名]

#.........这里部分代码省略.........
        """Test updating profile succeeds"""
        self.api.update_profile(include_entities='true')

    def test_update_profile_colors(self):
        """Test updating profile colors succeeds"""
        self.api.update_profile_colors(profile_background_color='3D3D3D')

    def test_list_blocks(self):
        """Test listing users who are blocked by the authenticated user
        succeeds"""
        self.api.list_blocks()

    def test_list_block_ids(self):
        """Test listing user ids who are blocked by the authenticated user
        succeeds"""
        self.api.list_block_ids()

    def test_create_block(self):
        """Test blocking a user succeeds"""
        self.api.create_block(screen_name='justinbieber')

    def test_destroy_block(self):
        """Test unblocking a user succeeds"""
        self.api.destroy_block(screen_name='justinbieber')

    def test_lookup_user(self):
        """Test listing a number of user objects succeeds"""
        self.api.lookup_user(screen_name='twitter,justinbieber')

    def test_show_user(self):
        """Test showing one user works"""
        self.api.show_user(screen_name='twitter')

    def test_search_users(self):
        """Test that searching for users succeeds"""
        self.api.search_users(q='Twitter API')

    def test_get_contributees(self):
        """Test returning list of accounts the specified user can
        contribute to succeeds"""
        self.api.get_contributees(screen_name='TechCrunch')

    def test_get_contributors(self):
        """Test returning list of accounts that contribute to the
        authenticated user fails because we are not a Contributor account"""
        self.assertRaises(TwythonError, self.api.get_contributors,
                          screen_name=screen_name)

    def test_remove_profile_banner(self):
        """Test removing profile banner succeeds"""
        self.api.remove_profile_banner()

    def test_get_profile_banner_sizes(self):
        """Test getting list of profile banner sizes fails because
        we have not uploaded a profile banner"""
        self.assertRaises(TwythonError, self.api.get_profile_banner_sizes)

    # Suggested Users
    def test_get_user_suggestions_by_slug(self):
        """Test getting user suggestions by slug succeeds"""
        self.api.get_user_suggestions_by_slug(slug='twitter')

    def test_get_user_suggestions(self):
        """Test getting user suggestions succeeds"""
        self.api.get_user_suggestions()
开发者ID:hungtrv,项目名称:twython,代码行数:69,代码来源:test_core.py

示例7: Twython

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import search_users [as 别名]
from twython import Twython

t = Twython(app_key='D8XxzNAHM6uUPRlnQJUIYDhex',       #REPLACE 'APP_KEY' WITH YOUR APP KEY, ETC., IN THE NEXT 4 LINES
    app_secret='bubnRJsyEVFchIzY4078GgrUCEZCtPgR83VKctSwYajurpHOrb',
    oauth_token='512739542-yp06o7mXg6Yrexxz7zdGqpETL5k44PxOYhVKN2bw',
    oauth_token_secret='cw9Z5PeK5YG7zuDtXpUZD40Apf2VFrUMo1XzWUHN6dn7F')

users = {}
for i in range(1, 2):
    results = t.search_users(q = '"dog" OR "man"')
    for user in results:
        users[user["id_str"].encode('utf-8')] = [user["location"].encode('utf-8'), user["lang"].encode('utf-8'), user["description"].encode('utf-8')]


print users
开发者ID:eng543,项目名称:genderClassification_postScraping,代码行数:17,代码来源:findUsers_twython.py

示例8: TwythonEndpointsTestCase

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import search_users [as 别名]

#.........这里部分代码省略.........
    @unittest.skip('skipping non-updated test')
    def test_list_blocks(self):
        """Test listing users who are blocked by the authenticated user
        succeeds"""
        self.api.list_blocks()

    @unittest.skip('skipping non-updated test')
    def test_list_block_ids(self):
        """Test listing user ids who are blocked by the authenticated user
        succeeds"""
        self.api.list_block_ids()

    @unittest.skip('skipping non-updated test')
    def test_create_block(self):
        """Test blocking a user succeeds"""
        self.api.create_block(screen_name='justinbieber')

    @unittest.skip('skipping non-updated test')
    def test_destroy_block(self):
        """Test unblocking a user succeeds"""
        self.api.destroy_block(screen_name='justinbieber')

    @unittest.skip('skipping non-updated test')
    def test_lookup_user(self):
        """Test listing a number of user objects succeeds"""
        self.api.lookup_user(screen_name='twitter,justinbieber')

    @unittest.skip('skipping non-updated test')
    def test_show_user(self):
        """Test showing one user works"""
        self.api.show_user(screen_name='twitter')

    @unittest.skip('skipping non-updated test')
    def test_search_users(self):
        """Test that searching for users succeeds"""
        self.api.search_users(q='Twitter API')

    @unittest.skip('skipping non-updated test')
    def test_get_contributees(self):
        """Test returning list of accounts the specified user can
        contribute to succeeds"""
        self.api.get_contributees(screen_name='TechCrunch')

    @unittest.skip('skipping non-updated test')
    def test_get_contributors(self):
        """Test returning list of accounts that contribute to the
        authenticated user fails because we are not a Contributor account"""
        self.assertRaises(TwythonError, self.api.get_contributors,
                          screen_name=screen_name)

    @unittest.skip('skipping non-updated test')
    def test_remove_profile_banner(self):
        """Test removing profile banner succeeds"""
        self.api.remove_profile_banner()

    @unittest.skip('skipping non-updated test')
    def test_get_profile_banner_sizes(self):
        """Test getting list of profile banner sizes fails because
        we have not uploaded a profile banner"""
        self.assertRaises(TwythonError, self.api.get_profile_banner_sizes)

    @unittest.skip('skipping non-updated test')
    def test_list_mutes(self):
        """Test listing users who are muted by the authenticated user
        succeeds"""
        self.api.list_mutes()
开发者ID:nouvak,项目名称:twython,代码行数:70,代码来源:test_endpoints.py


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