I am trying to retrieve a URL but keep running into an SSLError: HTTPSConnectionPool(host='developer.uspto.gov', port=443)
I am trying to retrieve a URL but keep running into an SSLError: HTTPSConnectionPool(host='developer.uspto.gov', port=443)
我正在尝试从 USPTO 设置的 API 中检索 URL。他们的系统为查询提供了一个URL,在网络浏览器中搜索时它工作得很好。但是我在 Python3
中这样做时一直收到此错误
我试过同时使用 urllib 和请求来检索数据。
我的代码:
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 证书验证的更多信息。
希望这对您有所帮助
您的 URL 似乎遇到了与 was seeing ( describes the problem; Here's the SSLLabs report on the host)
相同的问题
我能够通过从您的原始 URL 下载证书,将两个 Entrust 证书导出到它们自己的文件(Entrust Certification Authority - L1K & Entrust.net)来解决 SSL 问题,以及然后从中创建一个 .pem
信任链(响应中缺少 Entrust L1K 证书):
cat entrustL1K.cer entrustNET.cer > entrust_chain.pem
然后,您可以将此信任链传递给 requests.get
以修复响应:
url = "https://developer.uspto.gov/ibd-api/v1/patent/application?searchText=device&start=0&rows=2000"
requests.get(url, verify='entrust_chain.pem')
>>> <Response [200]>
我正在尝试从 USPTO 设置的 API 中检索 URL。他们的系统为查询提供了一个URL,在网络浏览器中搜索时它工作得很好。但是我在 Python3
中这样做时一直收到此错误我试过同时使用 urllib 和请求来检索数据。
我的代码:
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 证书验证的更多信息。
希望这对您有所帮助
您的 URL 似乎遇到了与
我能够通过从您的原始 URL 下载证书,将两个 Entrust 证书导出到它们自己的文件(Entrust Certification Authority - L1K & Entrust.net)来解决 SSL 问题,以及然后从中创建一个 .pem
信任链(响应中缺少 Entrust L1K 证书):
cat entrustL1K.cer entrustNET.cer > entrust_chain.pem
然后,您可以将此信任链传递给 requests.get
以修复响应:
url = "https://developer.uspto.gov/ibd-api/v1/patent/application?searchText=device&start=0&rows=2000"
requests.get(url, verify='entrust_chain.pem')
>>> <Response [200]>