Reputation: 271764
http://socksipy.sourceforge.net/
>>> import socks
>>> s = socks.socksocket()
>>> s.setproxy(socks.PROXY_TYPE_SOCKS5,"socks.example.com")
>>> s.connect(("www.example.com",80))
>>>
After I connect to the proxy, how do I download a webpage?
Note: I do not want to use "setdefaultproxy". I already have working code for this method.
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, proxy_ip, proxy_port)
socket.socket = socks.socksocket
socket.setdefaulttimeout(3)
my_ip = urllib2.urlopen('http://whatthehellismyip.com/?ipraw').read()
I want to use the "connect" method.
Upvotes: 1
Views: 1045
Reputation: 1010
I'm guessing a bit here as I haven't used that socksipy module but...
you probably need to send a header first
s.send('GET / HTTP 1.1 / Host: localhost');
or some such.. "" might even work.
and then read the buffer from socket as in:
resp = s.recv(4096);
while (len(resp) > 0):
print(resp);
resp = s.recv(4096);
Upvotes: 1