it not working at port 27977
i use python 2.45
import re
import mechanize
import socks
import socket
import string
import urllib2
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5,'174.68.97.216',27977)
socket.socket = socks.socksocket
timeouts = socket.setdefaulttimeout(20)
br = mechanize.Browser()
br.set_handle_redirect(True)
br.set_handle_robots(False)
br.set_handle_referer(True)
br.set_handle_refresh(True)
br.open("https://www.google.com")
# follow second link with element text matching regular expression
#response1 = br.follow_link(text_regex=r"cheese\s*shop", nr=1)
#assert br.viewing_html()
print br.title()
#print response1.geturl()
#print response1.info() # headers
#print response1.read() # body
print br.response().read()
###########
Traceback (most recent call last):
File "test_browser.py", line 23, in <module>
br.open("https://www.google.com")
File "build\bdist.win32\egg\mechanize\_mechanize.py", line 204, in open
File "build\bdist.win32\egg\mechanize\_mechanize.py", line 231, 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
please fix it
thanks
This is your error:
TypeError: __init__() takes exactly 2 arguments (3 given)
This line is wrong:
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5,'174.68.97.216',27977)
how to fix it ?
thanks
No, box2 is wrong. Socks5Error takes one explicit parameter, while __negotiatesocks5 instanciates it with two parameters.
To fix it, replace
raise Socks5Error(ord(resp[1]),_generalerrors[ord(resp[1])])withraise Socks5Error((ord(resp[1]),_generalerrors[ord(resp[1])]))in SocksiPy's source code.Anyway, you are getting this error while raising an exception telling you SocksiPy could not connect to the server.