爬取目标是https站点,目前环境是python2.7。requests.get("https://blog.pucipuci.cn/checkip.php",verify=False)
报警告/var/python2.7/lib/python2.7/site-packages/urllib3/util/ssl_.py:339: SNIMissingWarning: An HTTPS request has been made, but
the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an
incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this.
For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
SNIMissingWarning
/var/python2.7/lib/python2.7/site-packages/urllib3/util/ssl_.py:137: InsecurePlatformWarning: A true SSLContext object is not
available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can
upgrade to a newer version of Python to solve this. For more information, see
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning
虽然报警告,但内容还是有的。
处理pip install pyopenssl ndg-httpsclient pyasn1
安装失败
报错中有一个 No package 'libffi' found
处理yum install libffi-devel
虽然安装失败,但无法再重新安装 必须卸载原安装的包pip uninstall pyopenssl ndg-httpsclient pyasn1
pip install pyopenssl ndg-httpsclient pyasn1
报错:Could not find .egg-info directory in install record for cryptography>=1.9 (from pyopenssl)
处理pip install --upgrade setuptools pip
pip uninstall pyopenssl ndg-httpsclient pyasn1
pip install pyopenssl ndg-httpsclient pyasn1
再运行requests.get("https://blog.pucipuci.cn/checkip.php",verify=False)
还有一行警告,/var/python2.7/lib/python2.7/site-packages/urllib3/connectionpool.py:858: InsecureRequestWarning: Unverified HTTPS request is
being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-
usage.html#ssl-warnings
InsecureRequestWarning)
去掉 verify=Falserequests.get("https://blog.pucipuci.cn/checkip.php",verify=False)
成功html = requests.get("https://blog.pucipuci.cn/checkip.php")
print(html.content)
输出正确内容,无警告。
非特殊说明,本博所有文章均为博主原创。
最新文章