Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #5003
| Newsgroups | comp.lang.python |
|---|---|
| Subject | can't get urllib2 or httplib to work with tor & privoxy |
| From | Bob Fnord <bob@example.com> |
| Message-ID | <d5e2985d74a2117de3fd9ab09c99b799@msgid.frell.theremailer.net> (permalink) |
| Date | 2011-05-09 20:20 +0200 |
| Organization | Frell Anonymous Remailer |
Here's my python code:
import httplib, urllib2
proxy_handler = {'http' : 'localhost:8118',
'https' : 'localhost:8118'}
def connect_u2(url = 'http://ipid.shat.net/iponly/'):,
proxied = urllib2.ProxyHandler(proxy_handler)
opnr = urllib2.build_opener(proxied)
opnr.addheaders = [('User-agent', agent)]
rsp = opnr.open(url)
page = rsp.read()
return page
def connect_h(url = 'http://ipid.shat.net/iponly/'):
cnn = httplib.HTTPConnection('127.0.0.1', 8118)
cnn.connect()
cnn.request('GET', url)
rsp = cnn.getresponse()
stderr.write('%u %s\n' % (rsp.status, rsp.reason))
page = rsp.read(500)
cnn.close()
return page
Both methods give me a 503 error, even though this
export http_proxy='http://localhost:8118/'
lynx -dump 'http://ipid.shat.net/iponly/'
works in bash and prints out the IP of a tor exit.
What am I doing wrong in python? (I tried both 'localhost:8118' and
'http://localhost:8118/' in the proxy_handler dict.)
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
can't get urllib2 or httplib to work with tor & privoxy Bob Fnord <bob@example.com> - 2011-05-09 20:20 +0200
Re: can't get urllib2 or httplib to work with tor & privoxy Chris Angelico <rosuav@gmail.com> - 2011-05-10 20:33 +1000
Re: can't get urllib2 or httplib to work with tor & privoxy Bob Fnord <bob@example.com> - 2011-05-12 17:51 +0200
csiph-web