【问题标题】:Webscraping images through py jupyter通过 py jupyter 抓取图像
【发布时间】:2020-11-03 06:11:20
【问题描述】:

我正在尝试通过 jupyter 中的 py 从这个 url 抓取图像:https://www.adobe.com/products/catalog.html?sort=name&types=pf_252Fdesktop&types=pf_252Fmobile&types=pf_252Fweb&page=1,但是当运行下面的代码时,我得到了这个错误:

import requests from bs4 
import BeautifulSoup 
# download page page = "adobe.com/products/…" result = requests.get(page) 
# if successful parse the download into a BeautifulSoup object, which allows easy manipulation 
if result.status_code == 200: soup = BeautifulSoup(result.content, "html.parser")

Error: SSLError: HTTPSConnectionPool(host='www.adobe.com', port=443): Max retries exceeded with url: /products/catalog.html?sort=name&types=pf_252Fdesktop&types=pf_252Fmobile&types=pf_252Fweb&page=1 (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

关于修复错误的任何建议是什么根本问题? 谢谢

【问题讨论】:

  • 如果您提供一些示例代码来说明您当前如何尝试实现这一目标,将会有所帮助。它无法正确建立 SSL 连接,但没有任何代码,我们无法帮助调试。您可能还需要确保此活动确实遵循 robots.txt 和任何版权。
  • 谢谢,这是我目前的代码: import requests from bs4 import BeautifulSoup # download page page = "adobe.com/products/…" result = requests.get(page) # 如果成功,将下载解析成 BeautifulSoup对象,如果 result.status_code == 200 则允许轻松操作:soup = BeautifulSoup(result.content, "html.parser")

标签: python html image web-scraping


【解决方案1】:
In [23]: res = requests.get("https://www.adobe.com/products/catalog.html?sort=name&types=pf_252Fdesktop&types=pf_252Fm
    ...: obile&types=pf_252Fweb&page=1", verify=False)
/Users/abhilash.kr/anaconda3/envs/py37/lib/python3.7/site-packages/urllib3/connectionpool.py:1004: 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,

In [24]: res
Out[24]: <Response [200]>

您需要在get 方法中使用verify=False

【讨论】:

    猜你喜欢
    • 2018-12-06
    • 2021-03-25
    • 2011-09-20
    • 1970-01-01
    • 2016-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多