In [1]:
from birding.twitter import Twitter
twitter = Twitter.from_oauth_file()

In [2]:
url = 'http://www.amazon.com/Amazon-SK705DI-Echo/dp/B00X4WHP5E' # Amazon Echo product page
search_result = twitter.search.tweets(q=url, count=100)
search_result['search_metadata']


Out[2]:
{u'completed_in': 0.118,
 u'count': 100,
 u'max_id': 617018231207895040,
 u'max_id_str': u'617018231207895040',
 u'query': u'http%3A%2F%2Fwww.amazon.com%2FAmazon-SK705DI-Echo%2Fdp%2FB00X4WHP5E',
 u'refresh_url': u'?since_id=617018231207895040&q=http%3A%2F%2Fwww.amazon.com%2FAmazon-SK705DI-Echo%2Fdp%2FB00X4WHP5E&include_entities=1',
 u'since_id': 0,
 u'since_id_str': u'0'}

In [3]:
assert len(search_result['statuses']) > 0, 'Nothing matches search.'
search_result['statuses'][0]


Out[3]:
{u'contributors': None,
 u'coordinates': None,
 u'created_at': u'Fri Jul 03 17:13:04 +0000 2015',
 u'entities': {u'hashtags': [{u'indices': [17, 24], u'text': u'Amazon'},
   {u'indices': [25, 30], u'text': u'echo'},
   {u'indices': [101, 106], u'text': u'tech'}],
  u'media': [{u'display_url': u'pic.twitter.com/TM0F66XVcY',
    u'expanded_url': u'http://twitter.com/SXEElectronics/status/617018231207895040/photo/1',
    u'id': 617018231157587968,
    u'id_str': u'617018231157587968',
    u'indices': [107, 129],
    u'media_url': u'http://pbs.twimg.com/media/CJAWz-gWgAAvEZD.jpg',
    u'media_url_https': u'https://pbs.twimg.com/media/CJAWz-gWgAAvEZD.jpg',
    u'sizes': {u'large': {u'h': 652, u'resize': u'fit', u'w': 416},
     u'medium': {u'h': 652, u'resize': u'fit', u'w': 416},
     u'small': {u'h': 532, u'resize': u'fit', u'w': 340},
     u'thumb': {u'h': 150, u'resize': u'crop', u'w': 150}},
    u'type': u'photo',
    u'url': u'http://t.co/TM0F66XVcY'}],
  u'symbols': [],
  u'urls': [{u'display_url': u'buff.ly/1GTLSex',
    u'expanded_url': u'http://buff.ly/1GTLSex',
    u'indices': [78, 100],
    u'url': u'http://t.co/eT1C4t205A'}],
  u'user_mentions': [{u'id': 176774540,
    u'id_str': u'176774540',
    u'indices': [59, 67],
    u'name': u'CGP Grey',
    u'screen_name': u'cgpgrey'}]},
 u'favorite_count': 0,
 u'favorited': False,
 u'geo': None,
 u'id': 617018231207895040,
 u'id_str': u'617018231207895040',
 u'in_reply_to_screen_name': None,
 u'in_reply_to_status_id': None,
 u'in_reply_to_status_id_str': None,
 u'in_reply_to_user_id': None,
 u'in_reply_to_user_id_str': None,
 u'is_quote_status': False,
 u'lang': u'en',
 u'metadata': {u'iso_language_code': u'en', u'result_type': u'recent'},
 u'place': None,
 u'possibly_sensitive': False,
 u'retweet_count': 0,
 u'retweeted': False,
 u'source': u'<a href="http://bufferapp.com" rel="nofollow">Buffer</a>',
 u'text': u'Has anyone tried #Amazon #echo yet? Reviews look good, but @cgpgrey hated it. http://t.co/eT1C4t205A #tech http://t.co/TM0F66XVcY',
 u'truncated': False,
 u'user': {u'contributors_enabled': False,
  u'created_at': u'Wed Jun 03 11:44:15 +0000 2015',
  u'default_profile': False,
  u'default_profile_image': False,
  u'description': u'Better living through technology. Welcome to the future of the clock.',
  u'entities': {u'description': {u'urls': []},
   u'url': {u'urls': [{u'display_url': u'sxeelectronics.com',
      u'expanded_url': u'http://www.sxeelectronics.com',
      u'indices': [0, 22],
      u'url': u'http://t.co/PIt61hmI6Y'}]}},
  u'favourites_count': 14,
  u'follow_request_sent': False,
  u'followers_count': 45,
  u'following': False,
  u'friends_count': 395,
  u'geo_enabled': True,
  u'has_extended_profile': False,
  u'id': 3307022770,
  u'id_str': u'3307022770',
  u'is_translation_enabled': False,
  u'is_translator': False,
  u'lang': u'en',
  u'listed_count': 1,
  u'location': u'New York, USA',
  u'name': u'SXE Electronics',
  u'notifications': False,
  u'profile_background_color': u'000000',
  u'profile_background_image_url': u'http://abs.twimg.com/images/themes/theme1/bg.png',
  u'profile_background_image_url_https': u'https://abs.twimg.com/images/themes/theme1/bg.png',
  u'profile_background_tile': False,
  u'profile_banner_url': u'https://pbs.twimg.com/profile_banners/3307022770/1434378229',
  u'profile_image_url': u'http://pbs.twimg.com/profile_images/610447596641890304/wrCuxdI0_normal.jpg',
  u'profile_image_url_https': u'https://pbs.twimg.com/profile_images/610447596641890304/wrCuxdI0_normal.jpg',
  u'profile_link_color': u'D31145',
  u'profile_sidebar_border_color': u'000000',
  u'profile_sidebar_fill_color': u'000000',
  u'profile_text_color': u'000000',
  u'profile_use_background_image': False,
  u'protected': False,
  u'screen_name': u'SXEElectronics',
  u'statuses_count': 29,
  u'time_zone': None,
  u'url': u'http://t.co/PIt61hmI6Y',
  u'utc_offset': None,
  u'verified': False}}

In [4]:
import textwrap
for status in search_result['statuses']:
    print(textwrap.dedent(u"""
        @{screen_name} -- https://twitter.com/{screen_name}
        {text}
    """).strip().format(
        screen_name=status['user']['screen_name'],
        text=status['text'],
    ))
    print('')


@SXEElectronics -- https://twitter.com/SXEElectronics
Has anyone tried #Amazon #echo yet? Reviews look good, but @cgpgrey hated it. http://t.co/eT1C4t205A #tech http://t.co/TM0F66XVcY

@WildCougConfess -- https://twitter.com/WildCougConfess
http://t.co/BgkUw1tqDV

@tomdebaere -- https://twitter.com/tomdebaere
Amazon Echo: Always Ready, Connected, and Fast. #cool #wantone http://t.co/ONkIcTHMgN

@cortanabot -- https://twitter.com/cortanabot
Cortana &amp; Siri done right: AmazonEcho http://t.co/tC0NOrIEuw

@pcolazurdo -- https://twitter.com/pcolazurdo
#Cortana &amp; #Siri done right: #AmazonEcho http://t.co/uSuXHT2S1n #Iwantone

@assistapps -- https://twitter.com/assistapps
A smart assistant who can hear you despite disturbance. 
Alexa when is  bringing  Echo home http://t.co/9vyr7elBS3

@assistapps -- https://twitter.com/assistapps
have you tried? Amazon Echo http://t.co/9vyr7elBS3

@virgiliocorrado -- https://twitter.com/virgiliocorrado
@MarilynDenisCTV @darrenblamb @1045CHUMFM @RDMCHUMFM have you tried? Amazon Echo http://t.co/9fVBMvjFMu

@kelvinaiesec -- https://twitter.com/kelvinaiesec
小精靈就是了

 http://t.co/1LeA5GXD3h

@alanskyy -- https://twitter.com/alanskyy
#Amazon want's to know what goes on in your house, embrace #AmazonEcho, ease dropping at no extra charge . - http://t.co/QyeCwi21vB

@ShirlLacsamana -- https://twitter.com/ShirlLacsamana
RT @Dutchcowboy: really, i did not just order 2 more @amazonecho ’s ... 8-) http://t.co/2GCzBbqwJk

@Dutchcowboy -- https://twitter.com/Dutchcowboy
really, i did not just order 2 more @amazonecho ’s ... 8-) http://t.co/2GCzBbqwJk

@assistapps -- https://twitter.com/assistapps
A smart assistant who can hear you despite disturbance. 
Alexa when is  bringing  Echo home http://t.co/9vyr7elBS3

@stiver_ufo -- https://twitter.com/stiver_ufo
Amazon Echo is here http://t.co/gpEpeG81Hz

@Rachel__Ray -- https://twitter.com/Rachel__Ray
@notstevieb I need this for the @audible addiction http://t.co/YE3IFWOnVc @amazonecho

@marceloyamada -- https://twitter.com/marceloyamada
Mais um sinal de que o futuro já chegou. Assistente doméstico comandado por voz, disponível comercialmente por 180 d…https://t.co/im0eC80CVr

@Henrikop -- https://twitter.com/Henrikop
High expectations: Amazon Echo. IoT next level. AWS Lambda can however extend it to revolutionary heights...
http://t.co/spVYx9CDp7

@NEALDOG2007 -- https://twitter.com/NEALDOG2007
Amazon Echo: Always Ready, Connected, and Fast. http://t.co/oHuDRKolgP

@RunLove -- https://twitter.com/RunLove
Amazon Echo. Basically like Rosie from TheJetsons. But creepier... @MrMikeCalta @AngryGalvin @gregrahm @SeniorSpanish http://t.co/ltc7NiMmLD

@cz516 -- https://twitter.com/cz516
is @amazon's ECHO the next BIGGGG thing?

http://t.co/WBZsTBT7nx

@matthew1471 -- https://twitter.com/matthew1471
7 levels of creepy : http://t.co/XLWcNF6Z84

@aughban -- https://twitter.com/aughban
hey @AmazonUK when are you going to sell this http://t.co/12O23nMXMj in the UK?? Why don't you want my money?? :((((

@jserna -- https://twitter.com/jserna
Amazon Echo integration with WeMo and Hue interesting. But I'm waiting for HomeKit. http://t.co/0bGmTFXUgH

@madebyAi -- https://twitter.com/madebyAi
Will @Amazon Echo finally kick-off the revolution in voice-powered interfaces? http://t.co/M49QYXlmgL

@itchypaws -- https://twitter.com/itchypaws
Nice - you can use Amazon Echo to control your home when it integrates with WeMo http://t.co/mwW3slx5RF

@TeriRadichel -- https://twitter.com/TeriRadichel
Amazon Echo ~ Intrigued http://t.co/A8ecZynEHm

@klotzbrocken -- https://twitter.com/klotzbrocken
Amazon Echo ist in USA verfügbar. Der Retail muss sich einiges gefallen lassen #retailproblems http://t.co/UFW3SqHoMi http://t.co/eK3jZb4WVF


In [5]:
result_id = search_result['statuses'][0]['id']
twitter.statuses.show(_id=result_id)


Out[5]:
{u'contributors': None,
 u'coordinates': None,
 u'created_at': u'Fri Jul 03 17:13:04 +0000 2015',
 u'entities': {u'hashtags': [{u'indices': [17, 24], u'text': u'Amazon'},
   {u'indices': [25, 30], u'text': u'echo'},
   {u'indices': [101, 106], u'text': u'tech'}],
  u'media': [{u'display_url': u'pic.twitter.com/TM0F66XVcY',
    u'expanded_url': u'http://twitter.com/SXEElectronics/status/617018231207895040/photo/1',
    u'id': 617018231157587968,
    u'id_str': u'617018231157587968',
    u'indices': [107, 129],
    u'media_url': u'http://pbs.twimg.com/media/CJAWz-gWgAAvEZD.jpg',
    u'media_url_https': u'https://pbs.twimg.com/media/CJAWz-gWgAAvEZD.jpg',
    u'sizes': {u'large': {u'h': 652, u'resize': u'fit', u'w': 416},
     u'medium': {u'h': 652, u'resize': u'fit', u'w': 416},
     u'small': {u'h': 532, u'resize': u'fit', u'w': 340},
     u'thumb': {u'h': 150, u'resize': u'crop', u'w': 150}},
    u'type': u'photo',
    u'url': u'http://t.co/TM0F66XVcY'}],
  u'symbols': [],
  u'urls': [{u'display_url': u'buff.ly/1GTLSex',
    u'expanded_url': u'http://buff.ly/1GTLSex',
    u'indices': [78, 100],
    u'url': u'http://t.co/eT1C4t205A'}],
  u'user_mentions': [{u'id': 176774540,
    u'id_str': u'176774540',
    u'indices': [59, 67],
    u'name': u'CGP Grey',
    u'screen_name': u'cgpgrey'}]},
 u'extended_entities': {u'media': [{u'display_url': u'pic.twitter.com/TM0F66XVcY',
    u'expanded_url': u'http://twitter.com/SXEElectronics/status/617018231207895040/photo/1',
    u'id': 617018231157587968,
    u'id_str': u'617018231157587968',
    u'indices': [107, 129],
    u'media_url': u'http://pbs.twimg.com/media/CJAWz-gWgAAvEZD.jpg',
    u'media_url_https': u'https://pbs.twimg.com/media/CJAWz-gWgAAvEZD.jpg',
    u'sizes': {u'large': {u'h': 652, u'resize': u'fit', u'w': 416},
     u'medium': {u'h': 652, u'resize': u'fit', u'w': 416},
     u'small': {u'h': 532, u'resize': u'fit', u'w': 340},
     u'thumb': {u'h': 150, u'resize': u'crop', u'w': 150}},
    u'type': u'photo',
    u'url': u'http://t.co/TM0F66XVcY'}]},
 u'favorite_count': 0,
 u'favorited': False,
 u'geo': None,
 u'id': 617018231207895040,
 u'id_str': u'617018231207895040',
 u'in_reply_to_screen_name': None,
 u'in_reply_to_status_id': None,
 u'in_reply_to_status_id_str': None,
 u'in_reply_to_user_id': None,
 u'in_reply_to_user_id_str': None,
 u'is_quote_status': False,
 u'lang': u'en',
 u'place': None,
 u'possibly_sensitive': False,
 u'possibly_sensitive_appealable': False,
 u'retweet_count': 0,
 u'retweeted': False,
 u'source': u'<a href="http://bufferapp.com" rel="nofollow">Buffer</a>',
 u'text': u'Has anyone tried #Amazon #echo yet? Reviews look good, but @cgpgrey hated it. http://t.co/eT1C4t205A #tech http://t.co/TM0F66XVcY',
 u'truncated': False,
 u'user': {u'contributors_enabled': False,
  u'created_at': u'Wed Jun 03 11:44:15 +0000 2015',
  u'default_profile': False,
  u'default_profile_image': False,
  u'description': u'Better living through technology. Welcome to the future of the clock.',
  u'entities': {u'description': {u'urls': []},
   u'url': {u'urls': [{u'display_url': u'sxeelectronics.com',
      u'expanded_url': u'http://www.sxeelectronics.com',
      u'indices': [0, 22],
      u'url': u'http://t.co/PIt61hmI6Y'}]}},
  u'favourites_count': 14,
  u'follow_request_sent': False,
  u'followers_count': 45,
  u'following': False,
  u'friends_count': 395,
  u'geo_enabled': True,
  u'has_extended_profile': False,
  u'id': 3307022770,
  u'id_str': u'3307022770',
  u'is_translation_enabled': False,
  u'is_translator': False,
  u'lang': u'en',
  u'listed_count': 1,
  u'location': u'New York, USA',
  u'name': u'SXE Electronics',
  u'notifications': False,
  u'profile_background_color': u'000000',
  u'profile_background_image_url': u'http://abs.twimg.com/images/themes/theme1/bg.png',
  u'profile_background_image_url_https': u'https://abs.twimg.com/images/themes/theme1/bg.png',
  u'profile_background_tile': False,
  u'profile_banner_url': u'https://pbs.twimg.com/profile_banners/3307022770/1434378229',
  u'profile_image_url': u'http://pbs.twimg.com/profile_images/610447596641890304/wrCuxdI0_normal.jpg',
  u'profile_image_url_https': u'https://pbs.twimg.com/profile_images/610447596641890304/wrCuxdI0_normal.jpg',
  u'profile_link_color': u'D31145',
  u'profile_sidebar_border_color': u'000000',
  u'profile_sidebar_fill_color': u'000000',
  u'profile_text_color': u'000000',
  u'profile_use_background_image': False,
  u'protected': False,
  u'screen_name': u'SXEElectronics',
  u'statuses_count': 29,
  u'time_zone': None,
  u'url': u'http://t.co/PIt61hmI6Y',
  u'utc_offset': None,
  u'verified': False}}

In [6]:
result_id_pack = ','.join([status['id_str'] for status in search_result['statuses']])

In [7]:
lookup_result = twitter.statuses.lookup(_id=result_id_pack)
assert len(lookup_result) > 0, 'No statuses returned.'
type(lookup_result), len(lookup_result)


Out[7]:
(twitter.api.TwitterListResponse, 27)

In [8]:
lookup_result[0]


Out[8]:
{u'contributors': None,
 u'coordinates': None,
 u'created_at': u'Fri Jun 26 05:15:22 +0000 2015',
 u'entities': {u'hashtags': [],
  u'symbols': [],
  u'urls': [{u'display_url': u'amazon.com/Amazon-SK705DI\u2026',
    u'expanded_url': u'http://www.amazon.com/Amazon-SK705DI-Echo/dp/B00X4WHP5E',
    u'indices': [48, 70],
    u'url': u'http://t.co/oHuDRKolgP'}],
  u'user_mentions': []},
 u'favorite_count': 0,
 u'favorited': False,
 u'geo': None,
 u'id': 614300900107141120,
 u'id_str': u'614300900107141120',
 u'in_reply_to_screen_name': None,
 u'in_reply_to_status_id': None,
 u'in_reply_to_status_id_str': None,
 u'in_reply_to_user_id': None,
 u'in_reply_to_user_id_str': None,
 u'is_quote_status': False,
 u'lang': u'en',
 u'place': None,
 u'possibly_sensitive': True,
 u'retweet_count': 0,
 u'retweeted': False,
 u'source': u'<a href="http://twitter.com" rel="nofollow">Twitter Web Client</a>',
 u'text': u'Amazon Echo: Always Ready, Connected, and Fast. http://t.co/oHuDRKolgP',
 u'truncated': False,
 u'user': {u'contributors_enabled': False,
  u'created_at': u'Fri Nov 08 20:28:47 +0000 2013',
  u'default_profile': True,
  u'default_profile_image': False,
  u'description': u'',
  u'entities': {u'description': {u'urls': []},
   u'url': {u'urls': [{u'display_url': u'about.me/jerry.neal',
      u'expanded_url': u'http://about.me/jerry.neal',
      u'indices': [0, 22],
      u'url': u'http://t.co/VoUWmeCNiE'}]}},
  u'favourites_count': 5,
  u'follow_request_sent': False,
  u'followers_count': 191,
  u'following': False,
  u'friends_count': 1774,
  u'geo_enabled': False,
  u'has_extended_profile': False,
  u'id': 2182891302,
  u'id_str': u'2182891302',
  u'is_translation_enabled': False,
  u'is_translator': False,
  u'lang': u'en',
  u'listed_count': 6,
  u'location': u'',
  u'name': u'Jerry Neal',
  u'notifications': False,
  u'profile_background_color': u'C0DEED',
  u'profile_background_image_url': u'http://abs.twimg.com/images/themes/theme1/bg.png',
  u'profile_background_image_url_https': u'https://abs.twimg.com/images/themes/theme1/bg.png',
  u'profile_background_tile': False,
  u'profile_banner_url': u'https://pbs.twimg.com/profile_banners/2182891302/1387166654',
  u'profile_image_url': u'http://pbs.twimg.com/profile_images/460656132449509376/HgxE0bQO_normal.jpeg',
  u'profile_image_url_https': u'https://pbs.twimg.com/profile_images/460656132449509376/HgxE0bQO_normal.jpeg',
  u'profile_link_color': u'0084B4',
  u'profile_sidebar_border_color': u'C0DEED',
  u'profile_sidebar_fill_color': u'DDEEF6',
  u'profile_text_color': u'333333',
  u'profile_use_background_image': True,
  u'protected': False,
  u'screen_name': u'NEALDOG2007',
  u'statuses_count': 3576,
  u'time_zone': u'Central Time (US & Canada)',
  u'url': u'http://t.co/VoUWmeCNiE',
  u'utc_offset': -18000,
  u'verified': False}}