机械化:SSL:CERTIFICATE_VERIFY_FAILED

时间:2018-05-13 10:54:06

标签: python python-3.x python-2.7

我正在尝试为我的宿舍wifi创建一个自动登录脚本,我需要登录到wifi才能获得网络访问权限。如果我连接到wifi,网页将在本地网络上保持打开状态。我只需要访问该网页并登录。所以我试图使用mechanize登录。

这是python代码。

我现在只是想打印一下。

import mechanize
br = mechanize.Browser()
br.set_handle_robots(False)
br.open("https://192.168.10.3/connect/PortalMain")
for f in br.forms():
    print f

我得到的错误是

Traceback (most recent call last):
  File "demo.py", line 4, in <module>
    br.open("https://192.168.10.3/connect/PortalMain")
  File "/usr/local/lib/python2.7/site-packages/mechanize/_mechanize.py", line 254, in open
    return self._mech_open(url_or_request, data, timeout=timeout)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_mechanize.py", line 284, in _mech_open
    response = UserAgentBase.open(self, request, data)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_opener.py", line 195, in open
    response = urlopen(self, req, data)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 352, in _open
    '_open', req)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 340, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 1215, in https_open
    return self.do_open(conn_factory, req)
  File "/usr/local/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 1160, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)>

0 个答案:

没有答案