mechanize icon indicating copy to clipboard operation
mechanize copied to clipboard

mechanize.Browser() not working with socks have port is 27977

Open chym opened this issue 15 years ago • 1 comments

import socks import socket import mechanize

socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "76.73.239.33", 27977) socket.socket = socks.socksocket

br = mechanize.Browser()

br.open("https://www.google.com")

Traceback (most recent call last): File "tets1.py", line 16, in br.open("https://www.google.com") File "build\bdist.win32\egg\mechanize_mechanize.py", line 203, in open File "build\bdist.win32\egg\mechanize_mechanize.py", line 230, in _mech_open File "build\bdist.win32\egg\mechanize_opener.py", line 188, in open File "build\bdist.win32\egg\mechanize_http.py", line 316, in http_request File "build\bdist.win32\egg\mechanize_http.py", line 242, in read File "build\bdist.win32\egg\mechanize_mechanize.py", line 203, in open File "build\bdist.win32\egg\mechanize_mechanize.py", line 230, in _mech_open File "build\bdist.win32\egg\mechanize_opener.py", line 193, in open File "build\bdist.win32\egg\mechanize_urllib2_fork.py", line 344, in _open File "build\bdist.win32\egg\mechanize_urllib2_fork.py", line 332, in _call_chain File "build\bdist.win32\egg\mechanize_urllib2_fork.py", line 1170, in https_open File "build\bdist.win32\egg\mechanize_urllib2_fork.py", line 1115, in do_open File "V:\python\python.v2.54_portable\App\lib\httplib.py", line 866, in request self._send_request(method, url, body, headers) File "V:\python\python.v2.54_portable\App\lib\httplib.py", line 889, in _send_request self.endheaders() File "V:\python\python.v2.54_portable\App\lib\httplib.py", line 860, in endheaders self._send_output() File "V:\python\python.v2.54_portable\App\lib\httplib.py", line 732, in _send_output self.send(msg) File "V:\python\python.v2.54_portable\App\lib\httplib.py", line 699, in send self.connect() File "V:\python\python.v2.54_portable\App\lib\httplib.py", line 1134, in connect sock.connect((self.host, self.port)) File "V:\python\python.v2.54_portable\App\lib\site-packages\socks.py", line 369, in connect self.__negotiatesocks5(destpair[0],destpair[1]) File "V:\python\python.v2.54_portable\App\lib\site-packages\socks.py", line 236, in __negotiatesocks5 raise Socks5Error(ord(resp[1]),_generalerrors[ord(resp[1])]) TypeError: init() takes exactly 2 arguments (3 given)

Exit code: 1

chym avatar Sep 27 '10 01:09 chym

Looks like a bug in the Python socks library you're using -- presumably the TypeError refers to Socks5Error.init? If not, can you persuade me otherwise?

Note that even if valid, this would be a feature request rather than a bug (it's fine to record feature requests here in this tracker).

jjlee avatar Jan 04 '11 21:01 jjlee