Last change
on this file since 447 was
393,
checked in by Sam Hocevar, 18 years ago
|
|
-
Property svn:executable set to
*
|
File size:
1018 bytes
|
Rev | Line | |
---|
[393] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
| 3 | import urllib2, re, sys |
---|
| 4 | |
---|
| 5 | user_agent = "Mozilla/5.0" |
---|
| 6 | url = "http://www.phpbb.com/phpBB/" |
---|
| 7 | |
---|
| 8 | r = urllib2.Request(url + "profile.php?mode=register&agreed=true") |
---|
| 9 | r.add_header('User-Agent', user_agent) |
---|
| 10 | f = urllib2.build_opener().open(r) |
---|
| 11 | info = f.info() |
---|
| 12 | if info.has_key('set-cookie'): |
---|
| 13 | cookies = info['set-cookie'].split(";") |
---|
| 14 | cookiestr = "" |
---|
| 15 | for c in cookies: |
---|
| 16 | m = re.compile(".*(phpbb[^=]*=[^ ]*).*").match(c) |
---|
| 17 | if m: |
---|
| 18 | cookiestr += m.group(1) + "; " |
---|
| 19 | while True: |
---|
| 20 | l = f.readline() |
---|
| 21 | if not l: |
---|
| 22 | break |
---|
| 23 | m = re.compile(".*\"(profile[^\"]*confirm[^\"]*)\".*").match(l) |
---|
| 24 | if m: |
---|
| 25 | pic = m.group(1).replace("&", "&") |
---|
| 26 | r = urllib2.Request(url + pic) |
---|
| 27 | r.add_header('User-Agent', user_agent) |
---|
| 28 | r.add_header('Referer', url + "profile.php?mode=register&agreed=true") |
---|
| 29 | r.add_header('Cookie', cookiestr) |
---|
| 30 | r.add_header('Accept', "image/png,*/*;q=0.5") |
---|
| 31 | f = urllib2.build_opener().open(r) |
---|
| 32 | while True: |
---|
| 33 | l = f.readline() |
---|
| 34 | if not l: |
---|
| 35 | break |
---|
| 36 | sys.stdout.write(l) |
---|
| 37 | f.close() |
---|
| 38 | |
---|
Note: See
TracBrowser
for help on using the repository browser.