问题一

脚本内容

MacBookPro:Desktop mac$ cat wike.py
#!/usr/bin/python

from urllib.request import urlopen
from bs4 import BeautifulSoup
#import ssl

#ssl._create_default_https_context = ssl._create_unverified_context
html = urlopen("http://en.wikipedia.org/wiki/Kevin_Bacon")
bsObj = BeautifulSoup(html,"lxml")
for link in bsObj.findAll("a"):
    if 'href' in link.attrs:
        print(link.attrs['href'])

输出

报错

MacBookPro:Desktop mac$ python3 wike.py
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 1254, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1106, in request
    self._send_request(method, url, body, headers)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1151, in _send_request
    self.endheaders(body)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1102, in endheaders
    self._send_output(message_body)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 934, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 877, in send
    self.connect()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1260, in connect
    server_hostname=server_hostname)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 377, in wrap_socket
    _context=self)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 752, in __init__
    self.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 988, in do_handshake
    self._sslobj.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 633, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "wike.py", line 6, in <module>
    html = urlopen("http://en.wikipedia.org/wiki/Kevin_Bacon")
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 163, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 472, in open
    response = meth(req, response)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 582, in http_response
    'http', request, response, code, msg, hdrs)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 504, in error
    result = self._call_chain(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 696, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 466, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 484, in _open
    '_open', req)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 1297, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 1256, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)>
MacBookPro:Desktop mac$ echo $?
1

出了一堆的错,然后在 http://stackoverflow.com/questions/27835619/ssl-certificate-verify-failed-error 找到了答案:

要引入 一个ssl 的模块,然后,就没有然后了

问题二

Could not fetch URL https://pypi.python.org/simple/nltk/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749) - skipping
  Could not find a version that satisfies the requirement nltk (from versions: )
No matching distribution found for nltk

报了上面的错,下面的语句解决.

pip --trusted-host pypi.python.org install

问题三

<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645

 报了上面的错,下面的语句解决 

pip3 install certifi

最新文章

  1. 为什么 NaN 不等于自身?
  2. SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
  3. uploadfile图片上传和ashx
  4. 通过串口设备vid,pid自动获得该设备所对应的串口号
  5. 【大数处理、正则表达式】NYOJ-513
  6. Linux 平台下 YUM 源配置 手册
  7. Linux中的栈:用户态栈/内核栈/中断栈
  8. selenium webdriver启动Chrome浏览器后无法输入网址的解决办法
  9. UILabel 的使用,属性详解
  10. jQuery选取和操纵元素的特点
  11. Mysql字符集修改为UTF8
  12. 2016大连网络赛 Football Games
  13. oracle 数据库中的序列
  14. 使用配置文件自定义Ribbon配置
  15. Ubuntu中安装和配置 Java JDK,并卸载自带OpenJDK(以Ubuntu 14.04为例)
  16. docker cgroup技术之cpu和cpuset
  17. jquery-easyui:格式化列
  18. Vue项目中如何引用外部js
  19. 55. Jump Game(贪心)
  20. 疯狂JAVA——第五章 面向对象(上)

热门文章

  1. 51nod1091(贪心)
  2. 洛谷P1054 等价表达式
  3. 整合spring和hibernate框架
  4. centos 7 安装python3
  5. js new一个对象的过程,实现一个简单的new方法
  6. JS——面向对象、继承
  7. Spring AOP——Spring 中面向切面编程
  8. SVN的搭建(权限配置篇)
  9. 让zepto支持requirejs的方法
  10. asp.net MVC 4.0 Model元数据回顾——HtmlHelper的ModelMetadata