"Ju Hui" <[EMAIL PROTECTED]> writes:

> I wanna use urllib2 to get a page with a socks 5 proxy,who can give me
> a sample code ?
[...]

I haven't used it myself (though curiously, ftplib knows about this
module and will use it if present -- and urllib2 uses ftplib to fetch
ftp: URLs), but you could try this

http://www.w3.org/People/Connolly/drafts/socksForPython.html


And monkeypatch urllib2 (and everything else that uses module socket!)
something like so (UNTESTED):

import sys, os

os.environ['SOCKS_SERVER'] = 'joe:[EMAIL PROTECTED]'
import SOCKS
from socket import getfqdn
SOCKS.getfqdn = getfqdn
sys.modules['socket'] = SOCKS
del getfqdn, SOCKS

import urllib2


then just use urllib2 normally...



John

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to