gpt4 book ai didi

python - 我正在尝试检索 URL,但不断遇到 SSLError : HTTPSConnectionPool(host ='developer.uspto.gov' , port=443)

转载 作者:行者123 更新时间:2023-12-01 07:30:32 25 4
gpt4 key购买 nike

我正在尝试从 USPTO 设置的 API 检索 URL。他们的系统提供了一个用于查询的 URL,并且在网络浏览器中搜索时效果很好。但在 Python3 中这样做时我不断收到此错误

我尝试使用 urllib 和 requests 来检索数据。

我的代码:

import requests

link = new_url
f = requests.get("https://developer.uspto.gov/ibd-api/v1/patent/application?searchText=device&start=0&rows=2000")
print(f.text)

错误:

SSLError: HTTPSConnectionPool(host='developer.uspto.gov', port=443): Max 
retries exceeded with url: /ibd-api/v1/patent/application?
searchText=device&start=0&rows=2000 (Caused by SSLError(SSLError("bad
handshake: Error([('SSL routines', 'tls_process_server_certificate',
'certificate verify failed')])")))

我希望能够使用 json 库读取此 URL 的内容。

最佳答案

通过在您的获取请求中添加 verify = False 可以轻松解决此错误。

我建议用以下代码替换您当前的代码:

import requests

link = new_url
f = requests.get("https://developer.uspto.gov/ibd-api/v1/patent/application?searchText=device&start=0&rows=2000", verify=False)
print(f.text)

Here这是 SSL 证书验证的更多信息。

希望这有帮助

关于python - 我正在尝试检索 URL,但不断遇到 SSLError : HTTPSConnectionPool(host ='developer.uspto.gov' , port=443),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57222710/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com