python - Disable ssl certificate validation in mechanize -
i new python , trying access website using mechanize.
br = mechanize.browser() r=br.open("https://172.22.2.2/") which gives me following error:
traceback (most recent call last): file "<pyshell#4>", line 1, in <module> br.open("https://172.22.2.2/") file "/home/freeza/.local/lib/python2.7/site-packages/mechanize/_mechanize.py", line 203, in open return self._mech_open(url, data, timeout=timeout) file "/home/freeza/.local/lib/python2.7/site-packages/mechanize/_mechanize.py", line 230, in _mech_open response = useragentbase.open(self, request, data) file "/home/freeza/.local/lib/python2.7/site-packages/mechanize/_opener.py", line 193, in open response = urlopen(self, req, data) file "/home/freeza/.local/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 344, in _open '_open', req) file "/home/freeza/.local/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 332, in _call_chain result = func(*args) file "/home/freeza/.local/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 1170, in https_open return self.do_open(conn_factory, req) file "/home/freeza/.local/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 1118, in do_open raise urlerror(err) urlerror: <urlopen error [ssl: certificate_verify_failed] certificate verify failed (_ssl.c:590)> can tell me how disable ssl certificate validation in mechanize in python?
also can tell me how include certificate if it? thanks
add code snippet disable https certificate validation before br.open().
import ssl try: _create_unverified_https_context = ssl._create_unverified_context except attributeerror: # legacy python doesn't verify https certificates default pass else: # handle target environment doesn't support https verification ssl._create_default_https_context = _create_unverified_https_context
Comments
Post a Comment