http://www.tweepy.org/
'''
Created on 24/04/2014
usando tweepy se obtiene por stream la consulta YQL de tweeter epn
@author: Beto
'''
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
ckey = 'Blablalbalbalbalbalbalblabxxxlxlx'
csecret = 'Blablalbalbalbalbalbalblabxxxlxlx'
atoken = 'Blablalbalbalbalbalbalblabxxxlxlx'
atokensecret = 'Blablalbalbalbalbalbalblabxxxlxlx'
class StdOutListener(StreamListener):
def on_status(self,status):
print(status.text)
def on_data(self, data):
print data,
return True
def on_error(self, status):
print status
if __name__ == '__main__':
try:
l = StdOutListener()
auth = OAuthHandler(ckey, csecret)
auth.set_access_token( atoken, atokensecret)
stream = Stream(auth, l)
stream.filter( track = ['@epn'])
except Exception, e:
print str(e)
""" Algunas otras consultas en comentarios
YQL TEST almacden temporal de querys
select * from twitter.status.timeline.friends
where oauth_consumer_key="Blablalbalbalbalbalbalblabxxxlxlx"
and oauth_consumer_secret="Blablalbalbalbalbalbalblabxxxlxlx"
and oauth_token="2366526582-Blablalbalbalbalbalbalblabxxxlxlx"
and oauth_token_secret="Blablalbalbalbalbalbalblabxxxlxlx"
and id="@ExtractoCol"
Error SSL secure socket layer required
select * from twitter.status
where oauth_consumer_key="Blablalbalbalbalbalbalblabxxxlxlx"
and oauth_consumer_secret="Blablalbalbalbalbalbalblabxxxlxlx"
and oauth_token="2366526582-Blablalbalbalbalbalbalblabxxxlxlx"
and oauth_token_secret="Blablalbalbalbalbalbalblabxxxlxlx"
and id="ExtractoCol"
Si funciona
select * FROM twitter.search.tweets WHERE q='"politico rico" "hijo de perra"'
AND consumer_key="Blablalbalbalbalbalbalblabxxxlxlx"
AND consumer_secret="Blablalbalbalbalbalbalblabxxxlxlx"
AND access_token="2366526582-Blablalbalbalbalbalbalblabxxxlxlx"
AND access_token_secret="Blablalbalbalbalbalbalblabxxxlxlx"
Si funciona y tambien con q='"politico rico" "hijo de perra"'
select * FROM twitter.search.tweets WHERE
q="yahoo"
AND consumer_key="Blablalbalbalbalbalbalblabxxxlxlx"
AND consumer_secret="Blablalbalbalbalbalbalblabxxxlxlx"
AND access_token="1181240586-Blablalbalbalbalbalbalblabxxxlxlx"
AND access_token_secret="Blablalbalbalbalbalbalblabxxxlxlx"
select * FROM twitter.search.tweets WHERE q='"politico rico" "hijo de perra"'
AND consumer_key="Blablalbalbalbalbalbalblabxxxlxlx"
AND consumer_secret="Blablalbalbalbalbalbalblabxxxlxlx"
AND access_token="2366526582-Blablalbalbalbalbalbalblabxxxlxlx"
AND access_token_secret="Blablalbalbalbalbalbalblabxxxlxlx"
"""
Resultado del primer enunciado, aquel que invoca @epn
>>> runfile('C:/Users/Beto/workspace/PyDev/tests/tweepyStream.py', wdir=r'C:/Users/Beto/workspace/PyDev/tests')
{"created_at":"Mon Sep 11 23:34:05 +0000 2017","id":907386797147095040,"id_str":"907386797147095040","text":"@LupitaJuarezH @EPN @Formato21GRC Vamos a hacer casas, al fin q los damnificados no pagaran algunos impuestos, quie\u2026 https:\/\/t.co\/FlJEM25znb","display_text_range":[34,140],"source":"\u003ca href=\"http:\/\/twitter.com\/download\/android\" rel=\"nofollow\"\u003eTwitter for Android\u003c\/a\u003e","truncated":true,"in_reply_to_status_id":907384534873858048,"in_reply_to_status_id_str":"907384534873858048","in_reply_to_user_id":372919014,"in_reply_to_user_id_str":"372919014","in_reply_to_screen_name":"LupitaJuarezH","user":{"id":103466405,"id_str":"103466405","name":"ACSB","screen_name":"CoMeThUaUc","location":"MEXICO","url":null,"description":null,"translator_type":"none","protected":false,"verified":false,"followers_count":141,"friends_count":1007,"listed_count":1,"favourites_count":3305,"statuses_count":1383,"created_at":"Sun Jan 10 03:33:03 +0000 2010","utc_offset":-21600,"time_zone":"Mountain Time (US & Canada)","geo_enabled":false,"lang":"es","contributors_enabled":false,"is_translator":false,"profile_background_color":"352726","profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/66053406\/20071129090337-pocoyo1..jpg","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/66053406\/20071129090337-pocoyo1..jpg","profile_background_tile":true,"profile_link_color":"D02B55","profile_sidebar_border_color":"829D5E","profile_sidebar_fill_color":"99CC33","profile_text_color":"3E4415","profile_use_background_image":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/621582133\/vinfram.._normal.gif","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/621582133\/vinfram.._normal.gif","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,"extended_tweet":{"full_text":"@LupitaJuarezH @EPN @Formato21GRC Vamos a hacer casas, al fin q los damnificados no pagaran algunos impuestos, quien quite y nos perdonen algunos a nosotros. Vamos","display_text_range":[34,163],"entities":{"hashtags":[],"urls":[],"user_mentions":[{"screen_name":"LupitaJuarezH","name":"LupitaJuarez","id":372919014,"id_str":"372919014","indices":[0,14]},{"screen_name":"EPN","name":"Enrique Pe\u00f1a Nieto","id":2897441,"id_str":"2897441","indices":[15,19]},{"screen_name":"Formato21GRC","name":"FORMATO 21","id":104283869,"id_str":"104283869","indices":[20,33]}],"symbols":[]}},"quote_count":0,"reply_count":0,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[],"urls":[{"url":"https:\/\/t.co\/FlJEM25znb","expanded_url":"https:\/\/twitter.com\/i\/web\/status\/907386797147095040","display_url":"twitter.com\/i\/web\/status\/9\u2026","indices":[117,140]}],"user_mentions":[{"screen_name":"LupitaJuarezH","name":"LupitaJuarez","id":372919014,"id_str":"372919014","indices":[0,14]},{"screen_name":"EPN","name":"Enrique Pe\u00f1a Nieto","id":2897441,"id_str":"2897441","indices":[15,19]},{"screen_name":"Formato21GRC","name":"FORMATO 21","id":104283869,"id_str":"104283869","indices":[20,33]}],"symbols":[]},"favorited":false,"retweeted":false,"filter_level":"low","lang":"es","timestamp_ms":"1505172845528"}
{"created_at":"Mon Sep 11 23:34:07 +0000 2017","id":907386803493236736,"id_str":"907386803493236736","text":"En Vivo: Chiapas y Oaxaca, las entidades m\u00e1s afectadas por sismo: @EPN https:\/\/t.co\/G7doi7enej https:\/\/t.co\/6iRFin6y45","display_text_range":[0,94],"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":109651819,"id_str":"109651819","name":"FOROtv","screen_name":"Foro_TV","location":"M\u00e9xico DF","url":"http:\/\/www.forotv.com.mx","description":"El canal de informaci\u00f3n de la televisi\u00f3n mexicana","translator_type":"none","protected":false,"verified":true,"followers_count":1317152,"friends_count":552,"listed_count":6265,"favourites_count":809,"statuses_count":429961,"created_at":"Fri Jan 29 20:05:47 +0000 2010","utc_offset":-18000,"time_zone":"Mexico City","geo_enabled":true,"lang":"es","contributors_enabled":false,"is_translator":false,"profile_background_color":"709397","profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/625163355255222272\/6C-jyF4G.jpg","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/625163355255222272\/6C-jyF4G.jpg","profile_background_tile":true,"profile_link_color":"3B94D9","profile_sidebar_border_color":"000000","profile_sidebar_fill_color":"000000","profile_text_color":"000000","profile_use_background_image":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/859567046740377607\/N5y5qLmU_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/859567046740377607\/N5y5qLmU_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/109651819\/1497276791","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,"quote_count":0,"reply_count":0,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[],"urls":[{"url":"https:\/\/t.co\/G7doi7enej","expanded_url":"http:\/\/forotv.com.mx","display_url":"forotv.com.mx","indices":[71,94]}],"user_mentions":[{"screen_name":"EPN","name":"Enrique Pe\u00f1a Nieto","id":2897441,"id_str":"2897441","indices":[66,70]}],"symbols":[],"media":[{"id":907386756504240128,"id_str":"907386756504240128","indices":[95,118],"media_url":"http:\/\/pbs.twimg.com\/media\/DJevco9UQAALbp9.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/DJevco9UQAALbp9.jpg","url":"https:\/\/t.co\/6iRFin6y45","display_url":"pic.twitter.com\/6iRFin6y45","expanded_url":"https:\/\/twitter.com\/Foro_TV\/status\/907386803493236736\/photo\/1","type":"photo","sizes":{"medium":{"w":968,"h":523,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"large":{"w":968,"h":523,"resize":"fit"},"small":{"w":680,"h":367,"resize":"fit"}}}]},"extended_entities":{"media":[{"id":907386756504240128,"id_str":"907386756504240128","indices":[95,118],"media_url":"http:\/\/pbs.twimg.com\/media\/DJevco9UQAALbp9.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/DJevco9UQAALbp9.jpg","url":"https:\/\/t.co\/6iRFin6y45","display_url":"pic.twitter.com\/6iRFin6y45","expanded_url":"https:\/\/twitter.com\/Foro_TV\/status\/907386803493236736\/photo\/1","type":"photo","sizes":{"medium":{"w":968,"h":523,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"large":{"w":968,"h":523,"resize":"fit"},"small":{"w":680,"h":367,"resize":"fit"}}}]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"filter_level":"low","lang":"es","timestamp_ms":"1505172847041"}
{"created_at":"Mon Sep 11 23:34:09 +0000 2017","id":907386812485603328,"id_str":"907386812485603328","text":"RT @osoriochong: Ahora me encuentr....... y más....
{"created_at":"Mon Sep 11 23:34:05 +0000 2017","id":907386797147095040,"id_str":"907386797147095040","text":"@LupitaJuarezH @EPN @Formato21GRC Vamos a hacer casas, al fin q los damnificados no pagaran algunos impuestos, quie\u2026 https:\/\/t.co\/FlJEM25znb","display_text_range":[34,140],"source":"\u003ca href=\"http:\/\/twitter.com\/download\/android\" rel=\"nofollow\"\u003eTwitter for Android\u003c\/a\u003e","truncated":true,"in_reply_to_status_id":907384534873858048,"in_reply_to_status_id_str":"907384534873858048","in_reply_to_user_id":372919014,"in_reply_to_user_id_str":"372919014","in_reply_to_screen_name":"LupitaJuarezH","user":{"id":103466405,"id_str":"103466405","name":"ACSB","screen_name":"CoMeThUaUc","location":"MEXICO","url":null,"description":null,"translator_type":"none","protected":false,"verified":false,"followers_count":141,"friends_count":1007,"listed_count":1,"favourites_count":3305,"statuses_count":1383,"created_at":"Sun Jan 10 03:33:03 +0000 2010","utc_offset":-21600,"time_zone":"Mountain Time (US & Canada)","geo_enabled":false,"lang":"es","contributors_enabled":false,"is_translator":false,"profile_background_color":"352726","profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/66053406\/20071129090337-pocoyo1..jpg","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/66053406\/20071129090337-pocoyo1..jpg","profile_background_tile":true,"profile_link_color":"D02B55","profile_sidebar_border_color":"829D5E","profile_sidebar_fill_color":"99CC33","profile_text_color":"3E4415","profile_use_background_image":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/621582133\/vinfram.._normal.gif","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/621582133\/vinfram.._normal.gif","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,"extended_tweet":{"full_text":"@LupitaJuarezH @EPN @Formato21GRC Vamos a hacer casas, al fin q los damnificados no pagaran algunos impuestos, quien quite y nos perdonen algunos a nosotros. Vamos","display_text_range":[34,163],"entities":{"hashtags":[],"urls":[],"user_mentions":[{"screen_name":"LupitaJuarezH","name":"LupitaJuarez","id":372919014,"id_str":"372919014","indices":[0,14]},{"screen_name":"EPN","name":"Enrique Pe\u00f1a Nieto","id":2897441,"id_str":"2897441","indices":[15,19]},{"screen_name":"Formato21GRC","name":"FORMATO 21","id":104283869,"id_str":"104283869","indices":[20,33]}],"symbols":[]}},"quote_count":0,"reply_count":0,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[],"urls":[{"url":"https:\/\/t.co\/FlJEM25znb","expanded_url":"https:\/\/twitter.com\/i\/web\/status\/907386797147095040","display_url":"twitter.com\/i\/web\/status\/9\u2026","indices":[117,140]}],"user_mentions":[{"screen_name":"LupitaJuarezH","name":"LupitaJuarez","id":372919014,"id_str":"372919014","indices":[0,14]},{"screen_name":"EPN","name":"Enrique Pe\u00f1a Nieto","id":2897441,"id_str":"2897441","indices":[15,19]},{"screen_name":"Formato21GRC","name":"FORMATO 21","id":104283869,"id_str":"104283869","indices":[20,33]}],"symbols":[]},"favorited":false,"retweeted":false,"filter_level":"low","lang":"es","timestamp_ms":"1505172845528"}
{"created_at":"Mon Sep 11 23:34:07 +0000 2017","id":907386803493236736,"id_str":"907386803493236736","text":"En Vivo: Chiapas y Oaxaca, las entidades m\u00e1s afectadas por sismo: @EPN https:\/\/t.co\/G7doi7enej https:\/\/t.co\/6iRFin6y45","display_text_range":[0,94],"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":109651819,"id_str":"109651819","name":"FOROtv","screen_name":"Foro_TV","location":"M\u00e9xico DF","url":"http:\/\/www.forotv.com.mx","description":"El canal de informaci\u00f3n de la televisi\u00f3n mexicana","translator_type":"none","protected":false,"verified":true,"followers_count":1317152,"friends_count":552,"listed_count":6265,"favourites_count":809,"statuses_count":429961,"created_at":"Fri Jan 29 20:05:47 +0000 2010","utc_offset":-18000,"time_zone":"Mexico City","geo_enabled":true,"lang":"es","contributors_enabled":false,"is_translator":false,"profile_background_color":"709397","profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/625163355255222272\/6C-jyF4G.jpg","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/625163355255222272\/6C-jyF4G.jpg","profile_background_tile":true,"profile_link_color":"3B94D9","profile_sidebar_border_color":"000000","profile_sidebar_fill_color":"000000","profile_text_color":"000000","profile_use_background_image":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/859567046740377607\/N5y5qLmU_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/859567046740377607\/N5y5qLmU_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/109651819\/1497276791","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,"quote_count":0,"reply_count":0,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[],"urls":[{"url":"https:\/\/t.co\/G7doi7enej","expanded_url":"http:\/\/forotv.com.mx","display_url":"forotv.com.mx","indices":[71,94]}],"user_mentions":[{"screen_name":"EPN","name":"Enrique Pe\u00f1a Nieto","id":2897441,"id_str":"2897441","indices":[66,70]}],"symbols":[],"media":[{"id":907386756504240128,"id_str":"907386756504240128","indices":[95,118],"media_url":"http:\/\/pbs.twimg.com\/media\/DJevco9UQAALbp9.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/DJevco9UQAALbp9.jpg","url":"https:\/\/t.co\/6iRFin6y45","display_url":"pic.twitter.com\/6iRFin6y45","expanded_url":"https:\/\/twitter.com\/Foro_TV\/status\/907386803493236736\/photo\/1","type":"photo","sizes":{"medium":{"w":968,"h":523,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"large":{"w":968,"h":523,"resize":"fit"},"small":{"w":680,"h":367,"resize":"fit"}}}]},"extended_entities":{"media":[{"id":907386756504240128,"id_str":"907386756504240128","indices":[95,118],"media_url":"http:\/\/pbs.twimg.com\/media\/DJevco9UQAALbp9.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/DJevco9UQAALbp9.jpg","url":"https:\/\/t.co\/6iRFin6y45","display_url":"pic.twitter.com\/6iRFin6y45","expanded_url":"https:\/\/twitter.com\/Foro_TV\/status\/907386803493236736\/photo\/1","type":"photo","sizes":{"medium":{"w":968,"h":523,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"large":{"w":968,"h":523,"resize":"fit"},"small":{"w":680,"h":367,"resize":"fit"}}}]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"filter_level":"low","lang":"es","timestamp_ms":"1505172847041"}
{"created_at":"Mon Sep 11 23:34:09 +0000 2017","id":907386812485603328,"id_str":"907386812485603328","text":"RT @osoriochong: Ahora me encuentr....... y más....