User:Mirjam Dissel/JSON twitter API in Python: Difference between revisions
No edit summary |
mNo edit summary |
||
Line 30: | Line 30: | ||
#!/usr/bin/python | #!/usr/bin/python | ||
import | import sys, json, urllib2, os | ||
Revision as of 13:54, 21 January 2011
Friday 21 Jan 2011
#!/usr/bin/python
import sys, json, urllib2, os
f = urllib2.urlopen("http://search.twitter.com/search.json?q="+sys.argv[1])
data = json.load(f)
for r in data ["results"]:
print r["text"]
Chmod it by removing extension and in terminal:
chmod +x filename
execute by typing in terminal:
filename searchquery
Exact same story as above, now espeak read tweets out aloud:
#!/usr/bin/python
import sys, json, urllib2, os
f = urllib2.urlopen("http://search.twitter.com/search.json?q="+sys.argv[1])
data = json.load(f)
os.system("espeak cool")
for r in data ["results"]:
os.system('espeak "'+r["text"].encode("utf-8") + '"')