Skip to content

Instantly share code, notes, and snippets.

@Kevinstronger
Created February 20, 2014 01:54
Show Gist options
  • Save Kevinstronger/9105558 to your computer and use it in GitHub Desktop.
Save Kevinstronger/9105558 to your computer and use it in GitHub Desktop.
Sample for interacting with Reddit using Python 2.7
# reddit27_samp.py
# http://docs.python.org/release/2.5.2/lib/httplib-examples.html
import httplib
url_string = "www.reddit.com"
header_stuff = {"User-Agent":"blah blah blah"}
reddit_feed = "/r/skydiving.json"
conn = httplib.HTTPConnection(url_string)
conn.request(method="GET", url=reddit_feed, headers=header_stuff)
res = conn.getresponse()
data = res.read()
print(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment