Skip to content

Instantly share code, notes, and snippets.

@jrabbit
Created July 20, 2010 20:10
Show Gist options
  • Save jrabbit/483490 to your computer and use it in GitHub Desktop.
Save jrabbit/483490 to your computer and use it in GitHub Desktop.
from BeautifulSoup import BeautifulSoup
import re
import urllib2
import urllib
import cookielib
def grab(user, passwd):
values = {'user' : user, 'passwd' : passwd}
url = 'http://www.reddit.com/login?dest=/prefs/friends/'
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()
return the_page
if __name__ == "__main__":
import sys
user = sys.argv[1]
passwd = sys.argv[2]
html = grab(user, passwd)
soup = BeautifulSoup(html)
links = soup.findAll('a', href=re.compile('^http://www.reddit.com/user/.*'))
print links
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment