#!/usr/bin/env python3

import argparse

import tweepy

from util import logger, get_oauth_handler, EchoListener

parser = argparse.ArgumentParser(description="Connect to the sample stream endpoint.")
args = parser.parse_args()

stream = tweepy.streaming.Stream(get_oauth_handler(), EchoListener())

logger.info("Starting stream")
try:
    stream.sample()
except KeyboardInterrupt:
    logger.info("Received interrupt. Stopping stream...")
    stream.disconnect()
    logger.info("Disconnected")
Ejemplo n.º 2
0
#!/usr/bin/env python3

import argparse
import json

import tweepy

from util import get_oauth_handler, handle_rate_limit

parser = argparse.ArgumentParser(description="Fetch information about a Twitter user")
parser.add_argument("screen_name", help="User's screen name")
args = parser.parse_args()

api = tweepy.API(get_oauth_handler())

user = handle_rate_limit(api, "get_user", screen_name=args.screen_name)

print(json.dumps(user._json))