# set up trends. These are the default API access codes for the demo instance. key = "f9aaf865-b89a-444d-9070-38ec6666e539" secret = "9e13e4ac-ad93-4c8f-a896-d5a937b84c8a" c = StreamDrillClient("http://localhost:9669", key, secret) # Create a trend. # # The reason we're storing host and path seperately is because this allows # us to filter for the host. c.create("twitter-links", "host:path", 10000, ("day", "hour", "minute")) c.clear("twitter-links") # This will create a link-out button linking to the real-time search page # of Twitter for that link. Works like a charm (well, mostly) c.setMeta("twitter-links", "linkTemplate", "http://twitter.com/search/realtime?q=http://$1$2") def parsedate(ds): return datetime.datetime(*email.utils.parsedate(ds)[:6]) # Ok, extract the path and host part of the URL (by hand, I know, I know), # and update the trend. def analyzeurl(trend, url, ts): p = urlparse.urlparse(url) site = p.netloc path = p.path if not path: path = "/" c.update(trend, (site, path), timestamp=ts) #
# set up trends. These are the default API access codes for the demo instance. key = "f9aaf865-b89a-444d-9070-38ec6666e539" secret = "9e13e4ac-ad93-4c8f-a896-d5a937b84c8a" c = StreamDrillClient("http://localhost:9669", key, secret) # Create a trend. # # The reason we're storing host and path seperately is because this allows # us to filter for the host. c.create("twitter-links", "host:path", 10000, ("day", "hour", "minute")) c.clear("twitter-links") # This will create a link-out button linking to the real-time search page # of Twitter for that link. Works like a charm (well, mostly) c.setMeta("twitter-links", "linkTemplate", "http://twitter.com/search/realtime?q=http://$1$2") def parsedate(ds): return datetime.datetime(*email.utils.parsedate(ds)[:6]) # Ok, extract the path and host part of the URL (by hand, I know, I know), # and update the trend. def analyzeurl(trend, url, ts): p = urlparse.urlparse(url) site = p.netloc path = p.path if not path: path = "/" c.update(trend, (site, path), timestamp=ts)