Created
November 17, 2013 08:27
-
-
Save helxsz/7510822 to your computer and use it in GitHub Desktop.
Grab your twitter timeline and save in a json file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2.4 | |
import httplib, urllib, sys | |
twitter_handle = 'joemccann' | |
params = urllib.urlencode([ | |
('screen_name', twitter_handle) | |
]) | |
# Always use the following value for the Content-type header. | |
headers = { "Content-type": "application/x-www-form-urlencoded" } | |
conn = httplib.HTTPConnection('api.twitter.com') | |
conn.request('GET', '/1/statuses/user_timeline.json', params, headers) | |
response = conn.getresponse() | |
data = response.read() | |
conn.close | |
filename = "%s.json" % twitter_handle | |
print "\nWriting to file: %s\n" % filename | |
file = open(filename, 'w') | |
file.write(data) | |
file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment