美文网首页
Python网络数据采集P27程序报SSL错误

Python网络数据采集P27程序报SSL错误

作者: 扶墙师 | 来源:发表于2017-09-14 03:33 被阅读0次

调整如下:

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

相关文章

网友评论

      本文标题:Python网络数据采集P27程序报SSL错误

      本文链接:https://www.haomeiwen.com/subject/jmjrsxtx.html