Code Monkey home page Code Monkey logo

parallel-python-twitter's Introduction

parallel-python-twitter

Travis CI

A client that distributes Twitter API requests across multiple keys. Built for Python 3.6.

Getting Started

First, get your API credentials together and get a list of twitter.Api objects:

import parallel_twitter
TWITTER_API_CONSUMER_KEY = ...
TWITTER_API_CONSUMER_SECRET = ...
OAUTHS = [
    {
        'oauth_token': ...,
        'oauth_token_secret': ...
    },
    {
        'oauth_token': ...,
        'oauth_token_secret': ...
    },
    ...
]
apis = parallel_twitter.oauth_dicts_to_apis(
    oauth_dicts=OAUTHS,
    api_consumer_key=TWITTER_API_CONSUMER_KEY,
    api_consumer_secret=TWITTER_API_CONSUMER_SECRET
)

Next, try out some of the examples:

user_ids = [
    561808704, # @neeljsomani
    813286, # @BarackObama
    17919972 # @taylorswift13
]
# Get a list of posts that these users liked
parallel_twitter.examples.pull_users_likes(
    users=user_ids,
    apis=apis
)
# Get a list of these users' posts + number of likes
parallel_twitter.examples.pull_users_posts(
    users=user_ids,
    apis=apis
)

Comparison with Twint

Twint is a Python library for scraping data from Twitter.

  1. From Twint's documentation: "Twitter limits scrolls while browsing the user timeline. This means that with .Profile or with .Favorites you will be able to get ~3200 tweets." There are no such limits if you distribute your requests using parallel-python-twitter.
  2. Twitter will block your requests if you scrape enough (ex: twintproject/twint#682). I've tested parallel-python-twitter up to 100s of megabytes.
  3. Technically, twint violates Twitter's Terms of Service, since scraping is not permitted in general.

parallel-python-twitter's People

Contributors

neelsomani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

parallel-python-twitter's Issues

GetFollowersID

Hi, I've read this code and found that a function is not defined:

class GetFollowerIDs(TwitterOp):
    """
    An operator to get the IDs of the users that are following the requested
    user.
    """
    def _invoke(self,
                user_id: Optional[int] = None,
                screen_name: Optional[str] = None,
                cursor: int = -1,
                max_count: Optional[int] = None) -> Tuple[int, int, List[int]]:
        """
        Return the users that are following the specified user.
        Parameters
        ----------
        user_id : Optional[int]
            The Twitter ID of the specified user
        screen_name : Optional[str]
            The Twitter handle of the specified user
        cursor : int
            Cursor to identify the page to pull, starting at -1
        max_count : Optional[int]
            The maximum number of friends to return. Defaults to 5000.
        """
        return self.api.GetFollowerIDsPaged(
            user_id=user_id,
            screen_name=screen_name,
            cursor=cursor,
            count=max_count
        )

I am not sure where is GetFollowerIDsPaged defined. Also I tried run get_followers and could not get a large list.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.