Skip to content

Instantly share code, notes, and snippets.

@r-plus
Created March 17, 2012 05:45
Show Gist options
  • Select an option

  • Save r-plus/2055479 to your computer and use it in GitHub Desktop.

Select an option

Save r-plus/2055479 to your computer and use it in GitHub Desktop.
json practice.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import json
import datetime
userTimeline = urllib2.urlopen('http://api.twitter.com/1/statuses/user_timeline.json?screen_name=%s&count=3' % 'search_account')
contents = json.loads(userTimeline.read())
nowTime = datetime.datetime.now()
deltaTime = datetime.timedelta(minutes = 5)
for i in contents:
tweetedTime = datetime.datetime.strptime(i['created_at'], '%a %b %d %H:%M:%S +0000 %Y')
if tweetedTime > nowTime - deltaTime:
if u'search word' in i['text']:
print("Let's post notification!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment