Created
July 20, 2010 20:19
-
-
Save jrabbit/483505 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from BeautifulSoup import BeautifulSoup | |
import re | |
import urllib2 | |
import urllib | |
import cookielib | |
def grab(user, passwd): | |
values = {'user' : user, 'passwd' : passwd, 'dest' : "/prefs/friends/"} | |
url = 'http://www.reddit.com/post/login' | |
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) | |
print html | |
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