In [1]:
# Generate sample data.

import datetime
import random

URLS = [
    'http://time.com/3945677/greece-referendum-vote/',
    'http://fortune.com/this-week-in-photos-062715/',
    'http://www.bbc.com/news/technology-33379571',
]

class StepDatetimeGenerator(object):
    def __init__(self, now=None, step=None):
        if now is None:
            now = datetime.datetime.now()
        if step is None:
            step = datetime.timedelta(seconds=0.25)
        self.currently = now
        self._step = step

    def step(self):
        self.currently, dt = self.currently + self._step, self.currently
        return dt

def generate_url(urls=None):
    if urls is None:
        urls = URLS
    return random.choice(urls)

def generate_tuples(dt_gen=None, count=10):
    if dt_gen is None:
        start = datetime.datetime.now() - datetime.timedelta(seconds=1800)
        dt_gen = StepDatetimeGenerator()
    i = 0
    while i < count:
        yield generate_url(), dt_gen.step().isoformat()
        i += 1

In [2]:
# Define processing steps.

from birding import Twitter, TwitterSearchManager
manager = TwitterSearchManager(Twitter.from_oauth_file())

def search_url(*tup):
    url = tup[0]
    return manager.search(q=url)

def lookup_tweets(search_result):
    return manager.lookup_search_result(search_result)

def dump_lookup_result(lookup_result):
    return manager.dump(lookup_result)

In [3]:
# Put it all together.

for tup in generate_tuples(count=2):
    print(dump_lookup_result(lookup_tweets(search_url(*tup))))


@onnoh -- https://twitter.com/onnoh
BBC News - Reddit in uproar after staff sacking http://t.co/I1EJX0NVEe

@wopot -- https://twitter.com/wopot
#Reddit in uproar after staff sacking - BBC News
http://t.co/0aLr16ftFZ

@PaulineGrantTO -- https://twitter.com/PaulineGrantTO
Reddit in uproar after staff sacking - BBC News http://t.co/wVE75UHN47

@FactsVsOpinion -- https://twitter.com/FactsVsOpinion
RT @PaulineGrantTO: Reddit in uproar after staff sacking - BBC News http://t.co/wVE75UHN47

@kupathrak -- https://twitter.com/kupathrak
RT @wopot: #Reddit in uproar after staff sacking - BBC News
http://t.co/0aLr16ftFZ

@awrd -- https://twitter.com/awrd
Will be very interesting to see what happens. 'Reddit in uproar after staff sacking'  http://t.co/EotOibST8N

@lexinerus -- https://twitter.com/lexinerus
ReTw 8mw: It's amazing that reddit makes headlines like this and there are people who still don't even know what r… http://t.co/z5YC0iLdIp

@Narconavax -- https://twitter.com/Narconavax
BBC News - Reddit in uproar after staff sacking http://t.co/rENnPHOpx4

@elliotecweb -- https://twitter.com/elliotecweb
The world is turning upside-down: "Reddit in uproar after staff sacking" http://t.co/VJDYPhc7Tm

@jaszhix -- https://twitter.com/jaszhix
Reddit in uproar after staff sacking http://t.co/7VsgZakrst

@JenkoSchmidt -- https://twitter.com/JenkoSchmidt
You did this, somehow, didn't you, @TonyAbbottMHR? #Reddit #Auspol #RedditRevolt http://t.co/BIxtUb7rht

@8mw -- https://twitter.com/8mw
It's amazing that reddit makes headlines like this and there are people who still don't even know what reddit is. … http://t.co/8LxkVLsJKC

@Hideki_Manga -- https://twitter.com/Hideki_Manga
“Reddit in uproar after staff sacking” http://t.co/uA2WJX8EF0 HAHAHAHAA!

@lexinerus -- https://twitter.com/lexinerus
ReTw lexinerus: ReTw 8mw: It's amazing that reddit makes headlines like this and there are people who still don't … http://t.co/z5YC0iLdIp

@MatthewCallaway -- https://twitter.com/MatthewCallaway
Reddit in uproar after staff sacking - BBC News  http://t.co/HxZ2UHe9S9 #RedditRevolt
@tradingoptions2 -- https://twitter.com/tradingoptions2
This week in photos, June 27 &amp;#8211; July 3,&amp;nbsp;2015via @FortuneMagazine http://t.co/nQBRmUxWbJ

@editorialiste -- https://twitter.com/editorialiste
This week in photos, June 27 - July 3, 2015: http://t.co/GLyxPqJCpB

@tailoredapp1 -- https://twitter.com/tailoredapp1
RT @markgongloff: This week in photos http://t.co/SZnqTs2uHy via @FortuneMagazine