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


Python Twython.get_list_statuses方法代码示例

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


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

示例1: TwythonAPITestCase

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

#.........这里部分代码省略.........
        '''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()

    def test_get_user_suggestions_statuses_by_slug(self):
        '''Test getting status of suggested users succeeds'''
        self.api.get_user_suggestions_statuses_by_slug(slug='funny')

    # Favorites
    def test_get_favorites(self):
        '''Test getting list of favorites for the authenticated
        user succeeds'''
        self.api.get_favorites()

    def test_create_and_destroy_favorite(self):
        '''Test creating and destroying a favorite on a tweet succeeds'''
        self.api.create_favorite(id=test_tweet_id)
        self.api.destroy_favorite(id=test_tweet_id)

    # Lists
    def test_show_lists(self):
        '''Test show lists for specified user'''
        self.api.show_lists(screen_name='twitter')

    def test_get_list_statuses(self):
        '''Test timeline of tweets authored by members of the
        specified list succeeds'''
        self.api.get_list_statuses(list_id=test_list_id)

    def test_create_update_destroy_list_add_remove_list_members(self):
        '''Test create a list, adding and removing members then
        deleting the list succeeds'''
        the_list = self.api.create_list(name='Stuff')
        list_id = the_list['id_str']

        self.api.update_list(list_id=list_id, name='Stuff Renamed')

        # Multi add/delete members
        self.api.create_list_members(list_id=list_id,
                                     screen_name='johncena,xbox')
        self.api.delete_list_members(list_id=list_id,
                                     screen_name='johncena,xbox')

        # Single add/delete member
        self.api.add_list_member(list_id=list_id, screen_name='justinbieber')
        self.api.delete_list_member(list_id=list_id, screen_name='justinbieber')

        self.api.delete_list(list_id=list_id)

    def test_get_list_memberships(self):
        '''Test list of lists the authenticated user is a member of succeeds'''
        self.api.get_list_memberships()

    def test_get_list_subscribers(self):
        '''Test list of subscribers of a specific list succeeds'''
        self.api.get_list_subscribers(list_id=test_list_id)
开发者ID:chrisbol,项目名称:twython,代码行数:69,代码来源:test_twython.py

示例2: __init__

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import get_list_statuses [as 别名]
class TwitterBot:
    
    def __init__(self, name, con_k, con_s, acc_k, acc_s):
        self.name = name
        self.con_k = con_k
        self.con_s = con_s
        self.acc_k = acc_k
        self.acc_s = acc_s
        self.twitter = Twython(self.con_k, self.con_s, self.acc_k, self.acc_s)
        self.last_intervals = []
        # total number of trends you want to tweet
        self.num_trends = 3
        # number of seconds in a campaign window
        self.campaign_window = 600
        self.last_tweet = ""
        # tweets that will expire after a time limit
        self.temp_tweets = {}

    def tweet(self, msg):
        if self.twitter is not None:
            # > 140 char detection
            if len(msg) > 140:
                msg = msg[0:139]
            syslog.syslog('%s is tweeting %s' % (self.name, msg))
            try:
                tweet = self.twitter.update_status(status=msg)
                self.last_tweet = msg
                return tweet
            except Exception as e:
                syslog.syslog('%s error tweeting -> %s' % (self.name, str(e)))

    # Deletes a tweet from the given id
    def delete_tweet(self, tweet_id):
        if self.twitter is not None:
            try:
                destroyed = self.twitter.destroy_status(id=tweet_id)
                syslog.syslog('%s deleted %s' % (self.name, destroyed['text']))
                return destroyed
            except Exception as e:
                syslog.syslog('%s error deleting tweet -> %s' %(self.name, str(e)))

    # Deletes the most recent tweets
    def delete_tweets(self, num_tweets):
        if self.twitter is not None:
            try:
                timeline = self.twitter.get_user_timeline(screen_name = self.name, count = num_tweets)
                for tweet in timeline:
                    self.delete_tweet(tweet['id'])
                syslog.syslog('%s deleted %s tweet(s)' % (self.name, str(num_tweets)))
                return timeline
            except Exception as e:
                syslog.syslog('%s error deleting tweets -> %s' %(self.name, str(e)))


    # Replace all links in the text with the specified link
    def replace_link(self, text, link):
        replaced = ""
        for word in text.split():
            if word.startswith("http://") or word.startswith("https://"):
                replaced += link+" "
            else:
                replaced += word+" "
        replaced.strip()
        return replaced

    def retweet(self, tweet_id):
        if self.twitter is not None:
            try:
                tweet = self.twitter.retweet(id=tweet_id)
                syslog.syslog('%s is retweeting %s' % (self.name, tweet['text']))
                return tweet
            except Exception as e:
                syslog.syslog('%s error retweeting -> %s' %(self.name, str(e)))

    # This attack grabs a random tweet from a list of umich twitter accounts
    # If the tweet has a link it will be substituded for the attack link
    # The text of this modified tweet will then be tweeted by the bot
    # If the tweet does not have a link it is simply retweeted
    def repost_attack(self, link):
        if self.twitter is not None:
            try:
                #Get timeline of umich accounts
                umich_timeline = self.twitter.get_list_statuses(slug='UMich', owner_screen_name='JoseClark92', count=200)
                #Get user's timeline
                user_timeline = self.twitter.get_user_timeline(screen_name=self.name, count=100)
                #Get a random tweet that has not been posted by this bot
                repost = None
                while repost is None:
                    rand_tweet = random.choice(umich_timeline)
                    for tweet in user_timeline:
                        if rand_tweet['text'] in tweet: continue
                    repost = rand_tweet

                #If the tweet contains a link, replace the link and tweet it
                if "http" in repost['text']:
                    replaced = self.replace_link(repost['text'], link)
                    tweet = self.tweet(replaced)
                    #Add to the list of temporary tweets
                    self.temp_tweets[tweet['id']] = datetime.now()
                    return replaced
#.........这里部分代码省略.........
开发者ID:Dlarej,项目名称:security-privacy-botnet-project,代码行数:103,代码来源:birdie.py

示例3: Twython

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import get_list_statuses [as 别名]
#! usr/bin/env python

import sys
import os
from twython import Twython
import json

consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''

slug_name = sys.argv[1]
owner_name = ""
tweet_file_dir_path = ""

twitter = Twython(consumer_key, consumer_secret, oauth_version=2)
ACCESS_TOKEN = twitter.obtain_access_token()
twitter = Twython(consumer_key, access_token=ACCESS_TOKEN)

result_list = twitter.get_list_statuses(slug=slug_name,owner_screen_name='',include_rts='false',count='75')
for result in result_list:
	file_name = os.getenv('HOME')+ tweet_file_dir_path +slug_name[7:10]+'_'+str(result['id'])+'.json'
	with open(file_name, 'w') as outfile:
		json.dump(result, outfile)

开发者ID:bizentass,项目名称:daily_tweet_indexer,代码行数:27,代码来源:twitter_search_twython.py

示例4: TwitterHelper

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

#.........这里部分代码省略.........
            place = result["result"]["places"][0]
            location.place_id_twitter = place["id"]

            return location
        else:
            return None

    @retry(**retry_args)
    def update_profile_image(self, file_path):
        if file_path:
            logger.info("updating profile image %s" % file_path)
            with open(file_path, 'rb') as file:
                self.twitter.update_profile_image(image=file)

    @retry(**retry_args)
    def update_profile_banner_image(self, file_path):
        if file_path:
            logger.info("updating banner image %s" % file_path)
            with open(file_path, 'rb') as file:
                try:
                    self.twitter.update_profile_banner_image(banner=file)
                except TwythonError as ex:
                    if "Response was not valid JSON" in str(ex):
                        # twython issue i think
                        logger.warning(ex)
                    else:
                        raise

    @retry(**retry_args)
    def update_profile(self, **kwargs):
        return self.twitter.update_profile(**kwargs)

    @retry(**retry_args)
    def get_list_statuses(self, **kwargs):
        return self.twitter.get_list_statuses(**kwargs)

    @retry(**retry_args)
    def get_user_suggestions_by_slug(self, **kwargs):
        return self.twitter.get_user_suggestions_by_slug(**kwargs)

    @retry(**retry_args)
    def get_user_suggestions(self, **kwargs):
        return self.twitter.get_user_suggestions(**kwargs)

    @retry(**retry_args)
    def lookup_status(self, **kwargs):
        return self.twitter.lookup_status(**kwargs)

    @retry(**retry_args)
    def get_followers(self, **kwargs):
        kwargs["stringify_ids"] = True
        followers = set()
        cursor = -1
        while cursor != "0":
            kwargs["cursor"] = cursor
            logger.info("getting followers")
            response = self.twitter.get_followers_ids(**kwargs)
            cursor = response["next_cursor_str"]
            followers = followers.union(set(response["ids"]))

        return followers

    @retry(**retry_args)
    def get_following(self, **kwargs):
        kwargs["stringify_ids"] = True
        following = set()
开发者ID:andrewtatham,项目名称:twitterpibot,代码行数:70,代码来源:twitterhelper.py

示例5: TwythonAPITestCase

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

#.........这里部分代码省略.........
        """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()

    def test_get_user_suggestions_statuses_by_slug(self):
        """Test getting status of suggested users succeeds"""
        self.api.get_user_suggestions_statuses_by_slug(slug='funny')

    # Favorites
    def test_get_favorites(self):
        """Test getting list of favorites for the authenticated
        user succeeds"""
        self.api.get_favorites()

    def test_create_and_destroy_favorite(self):
        """Test creating and destroying a favorite on a tweet succeeds"""
        self.api.create_favorite(id=test_tweet_id)
        self.api.destroy_favorite(id=test_tweet_id)

    # Lists
    def test_show_lists(self):
        """Test show lists for specified user"""
        self.api.show_lists(screen_name='twitter')

    def test_get_list_statuses(self):
        """Test timeline of tweets authored by members of the
        specified list succeeds"""
        self.api.get_list_statuses(list_id=test_list_id)

    def test_create_update_destroy_list_add_remove_list_members(self):
        """Test create a list, adding and removing members then
        deleting the list succeeds"""
        the_list = self.api.create_list(name='Stuff')
        list_id = the_list['id_str']

        self.api.update_list(list_id=list_id, name='Stuff Renamed')

        screen_names = ['johncena', 'xbox']
        # Multi add/delete members
        self.api.create_list_members(list_id=list_id,
                                     screen_name=screen_names)
        self.api.delete_list_members(list_id=list_id,
                                     screen_name=screen_names)

        # Single add/delete member
        self.api.add_list_member(list_id=list_id, screen_name='justinbieber')
        self.api.delete_list_member(list_id=list_id, screen_name='justinbieber')

        self.api.delete_list(list_id=list_id)

    def test_get_list_subscribers(self):
        """Test list of subscribers of a specific list succeeds"""
        self.api.get_list_subscribers(list_id=test_list_id)

    def test_subscribe_is_subbed_and_unsubscribe_to_list(self):
        """Test subscribing, is a list sub and unsubbing to list succeeds"""
        self.api.subscribe_to_list(list_id=test_list_id)
开发者ID:hungtrv,项目名称:twython,代码行数:70,代码来源:test_core.py

示例6: Twython

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

from twython import Twython

import qactweet.util
import qactweet.sentiment

APP_KEY = ''
APP_SECRET = ''
OAUTH_TOKEN = ''
OAUTH_TOKEN_SECRET = ''

api = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)

list_timeline = api.get_list_statuses(slug='', owner_screen_name='', count=n)

conn = MySQLdb.connect('host','user','password','database', charset='utf8',
                     use_unicode=True)
c = conn.cursor()

logger = logging.getLogger('Stream_Logger')
formatter = logging.Formatter('%(asctime)s %(levelname)-8s %(message)s')

# Create a handler to write low-priority messages to a file.
handler = logging.FileHandler(filename='timeline.log')
handler.setLevel(logging.DEBUG)
handler.setFormatter(formatter)
logger.addHandler(handler)

warnings.filterwarnings('ignore', category=MySQLdb.Warning)
开发者ID:coderxiaok,项目名称:Twitter-Project,代码行数:33,代码来源:timeline.py

示例7: TwythonEndpointsTestCase

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

#.........这里部分代码省略.........
        """Test getting user suggestions by slug succeeds"""
        self.api.get_user_suggestions_by_slug(slug='twitter')

    @unittest.skip('skipping non-updated test')
    def test_get_user_suggestions(self):
        """Test getting user suggestions succeeds"""
        self.api.get_user_suggestions()

    @unittest.skip('skipping non-updated test')
    def test_get_user_suggestions_statuses_by_slug(self):
        """Test getting status of suggested users succeeds"""
        self.api.get_user_suggestions_statuses_by_slug(slug='funny')

    # Favorites
    @unittest.skip('skipping non-updated test')
    def test_get_favorites(self):
        """Test getting list of favorites for the authenticated
        user succeeds"""
        self.api.get_favorites()

    @unittest.skip('skipping non-updated test')
    def test_create_and_destroy_favorite(self):
        """Test creating and destroying a favorite on a tweet succeeds"""
        self.api.create_favorite(id=test_tweet_id)
        self.api.destroy_favorite(id=test_tweet_id)

    # Lists
    @unittest.skip('skipping non-updated test')
    def test_show_lists(self):
        """Test show lists for specified user"""
        self.api.show_lists(screen_name='twitter')

    @unittest.skip('skipping non-updated test')
    def test_get_list_statuses(self):
        """Test timeline of tweets authored by members of the
        specified list succeeds"""
        self.api.get_list_statuses(slug=test_list_slug,
                                   owner_screen_name=test_list_owner_screen_name)

    @unittest.skip('skipping non-updated test')
    def test_create_update_destroy_list_add_remove_list_members(self):
        """Test create a list, adding and removing members then
        deleting the list succeeds"""
        the_list = self.api.create_list(name='Stuff %s' % int(time.time()))
        list_id = the_list['id_str']

        self.api.update_list(list_id=list_id, name='Stuff Renamed \
                             %s' % int(time.time()))

        screen_names = ['johncena', 'xbox']
        # Multi add/delete members
        self.api.create_list_members(list_id=list_id,
                                     screen_name=screen_names)
        self.api.delete_list_members(list_id=list_id,
                                     screen_name=screen_names)

        # Single add/delete member
        self.api.add_list_member(list_id=list_id, screen_name='justinbieber')
        self.api.delete_list_member(list_id=list_id,
                                    screen_name='justinbieber')

        self.api.delete_list(list_id=list_id)

    @unittest.skip('skipping non-updated test')
    def test_get_list_memberships(self):
        """Test list of memberhips the authenticated user succeeds"""
开发者ID:nouvak,项目名称:twython,代码行数:70,代码来源:test_endpoints.py

示例8: raw_input

# 需要导入模块: from twython import Twython [as 别名]
# 或者: from twython.Twython import get_list_statuses [as 别名]
# Post
post = raw_input("Write your tweet: ")
twitter.update_status(status=post)

# Get timelines
print twitter.get_user_timeline(screen_name = "name")
print twitter.get_home_timeline(count = 5)

# Search
print twitter.search(q="linux", result_type="popular")

# Follow
twitter.create_friendship(screen_name = "LinuxUserMag")

# Retweet
twitter.retweet(id = "12345")

# Favouriting
twitter.create_favorite(id = "12345")
print twitter.get_favorites()

# Mentions
print twitter.get_mentions_timeline(count="5")

# Trending
print twitter.get_place_trends(id="1")

# Retrieve lists
print twitter.get_list_statuses(id = "12345")
开发者ID:codefitz,项目名称:twerter,代码行数:31,代码来源:Twerter.py


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