In [3]:
import tweepy

In [4]:
consumer_key = 'M6OkpsVkxMo1m4oEpcKrxTG9L'
consumer_secret = 'huUxJYdPoddEkvRrmDOFQIuHspkBERTCshx2J5tcj7FeAFdgNp'
access_token = '13101632-jfzgS37obVEw5vEQhkg3iHuMSgZFwAnLz55OZcVyi'
access_token_secret = 'CeoEHGH6fzrFH1PbXxSwCvmL04rD6nQElJzKgMnAj9AY9'

In [5]:
autorizar = tweepy.OAuthHandler(consumer_key,consumer_secret)

In [6]:
autorizar.set_access_token(access_token,access_token_secret)

In [7]:
class DadosPublicosTwitter(tweepy.StreamListener):
    def __init__(self):
        self.arquivo = open('tweets.json', mode='a')
    def on_data(self, dados):
        print('-->', dados)
        return False

In [8]:
dados_twitter = DadosPublicosTwitter()

In [9]:
fluxo = tweepy.Stream(autorizar,dados_twitter)

In [10]:
try:
    fluxo.filter(track=['folha','folha de s.paulo', 'folha de sao paulo'])
except KeyboardInterrupt:
    print("\n Finalizado via teclado")


--> {"created_at":"Mon Aug 01 23:34:18 +0000 2016","id":760257378734538752,"id_str":"760257378734538752","text":"vish @lyliaroz https:\/\/t.co\/PLpvtV7N0H","source":"\u003ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003eTwitter Web Client\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":32750227,"id_str":"32750227","name":"Vanildo","screen_name":"vanildofelix","location":null,"url":null,"description":"para a tropa do trapo vazo a tripa","protected":false,"verified":false,"followers_count":129,"friends_count":90,"listed_count":2,"favourites_count":740,"statuses_count":15989,"created_at":"Sat Apr 18 02:56:21 +0000 2009","utc_offset":-10800,"time_zone":"Santiago","geo_enabled":true,"lang":"pt","contributors_enabled":false,"is_translator":false,"profile_background_color":"131516","profile_background_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme14\/bg.gif","profile_background_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme14\/bg.gif","profile_background_tile":true,"profile_link_color":"009999","profile_sidebar_border_color":"EEEEEE","profile_sidebar_fill_color":"EFEFEF","profile_text_color":"333333","profile_use_background_image":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/541726929720987648\/FMna1HwB_normal.jpeg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/541726929720987648\/FMna1HwB_normal.jpeg","default_profile":false,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"quoted_status_id":760243484129460224,"quoted_status_id_str":"760243484129460224","quoted_status":{"created_at":"Mon Aug 01 22:39:05 +0000 2016","id":760243484129460224,"id_str":"760243484129460224","text":"Conhe\u00e7a F\u00e9lix, o gato rabugento e vesguinho que \u00e9 popular nas redes sociais https:\/\/t.co\/nsCoNEkKw4 https:\/\/t.co\/vkBZkZN0DW","source":"\u003ca href=\"https:\/\/about.twitter.com\/products\/tweetdeck\" rel=\"nofollow\"\u003eTweetDeck\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":14594813,"id_str":"14594813","name":"Folha de S.Paulo","screen_name":"folha","location":"S\u00e3o Paulo, Brazil","url":"http:\/\/www.folha.com.br","description":"Perfil oficial do jornal Folha de S.Paulo.\r\nNo Facebook: http:\/\/on.fb.me\/wFiUk9.\r\nAtendimento: @folha_atende","protected":false,"verified":true,"followers_count":4923030,"friends_count":190365,"listed_count":9071,"favourites_count":43,"statuses_count":243495,"created_at":"Wed Apr 30 02:33:39 +0000 2008","utc_offset":-10800,"time_zone":"Brasilia","geo_enabled":true,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"C0DEED","profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/341066973\/fundo_folha.gif","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/341066973\/fundo_folha.gif","profile_background_tile":false,"profile_link_color":"0084B4","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/2611288520\/gfiw6lklhvm09f530wp4_normal.jpeg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/2611288520\/gfiw6lklhvm09f530wp4_normal.jpeg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/14594813\/1452190707","default_profile":false,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":22,"favorite_count":70,"entities":{"hashtags":[],"urls":[{"url":"https:\/\/t.co\/nsCoNEkKw4","expanded_url":"http:\/\/uol.com\/bmjQ85","display_url":"uol.com\/bmjQ85","indices":[76,99]}],"user_mentions":[],"symbols":[],"media":[{"id":760243449639632897,"id_str":"760243449639632897","indices":[100,123],"media_url":"http:\/\/pbs.twimg.com\/media\/CoztY7aWgAECy8U.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/CoztY7aWgAECy8U.jpg","url":"https:\/\/t.co\/vkBZkZN0DW","display_url":"pic.twitter.com\/vkBZkZN0DW","expanded_url":"http:\/\/twitter.com\/folha\/status\/760243484129460224\/photo\/1","type":"photo","sizes":{"large":{"w":600,"h":600,"resize":"fit"},"medium":{"w":600,"h":600,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"small":{"w":600,"h":600,"resize":"fit"}}}]},"extended_entities":{"media":[{"id":760243449639632897,"id_str":"760243449639632897","indices":[100,123],"media_url":"http:\/\/pbs.twimg.com\/media\/CoztY7aWgAECy8U.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/CoztY7aWgAECy8U.jpg","url":"https:\/\/t.co\/vkBZkZN0DW","display_url":"pic.twitter.com\/vkBZkZN0DW","expanded_url":"http:\/\/twitter.com\/folha\/status\/760243484129460224\/photo\/1","type":"photo","sizes":{"large":{"w":600,"h":600,"resize":"fit"},"medium":{"w":600,"h":600,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"small":{"w":600,"h":600,"resize":"fit"}}}]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"filter_level":"low","lang":"pt"},"is_quote_status":true,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[],"urls":[{"url":"https:\/\/t.co\/PLpvtV7N0H","expanded_url":"https:\/\/twitter.com\/folha\/status\/760243484129460224","display_url":"twitter.com\/folha\/status\/7\u2026","indices":[15,38]}],"user_mentions":[{"screen_name":"lyliaroz","name":"Maria Lydia Aroz","id":2646072967,"id_str":"2646072967","indices":[5,14]}],"symbols":[]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"filter_level":"low","lang":"en","timestamp_ms":"1470094458646"}


In [ ]: