python - 尝试将 eBay 查找 sdk 与 python 一起使用时出现连接错误
问题描述
最近,当我尝试使用 eBay 查找 SDK 与 python 连接以发出请求时,我收到了连接错误。错误打印没有说明什么是错误的。
这是我为发出 API 请求而编写的 python 脚本。
from ebaysdk.finding import Connection as find_connect
import xmltodict
APP_ID = 'ActualID was removed-PRD-For privacy'
# keywords = input("Enter search keywords(e.g 'white board'): ")
api = find_connect(appid=APP_ID, config_file=None, siteid="EBAY-ENCA")
request = {
'keywords': "Iphone x 64gb",
'itemFilter': [
{'name': 'Condition', 'value': 'Used'},
{'name': 'currency', 'value': 'CAD'},
{'name': 'minPrice', 'value': 100.0}
],
'paginationInput': {
'entriesPerPage': 100,
'pageNumber': 10
},
}
resp = api.execute('findItemsByKeywords', request).dict() # Change from XML to dictionary
当我运行脚本时,我得到了这个错误
Traceback (most recent call last):
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 1322, in getresponse
response.begin()
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 303, in begin
version, status, reason = self._read_status()
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 264, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 719, in urlopen
retries = retries.increment(
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\retry.py", line 400, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\packages\six.py", line 734, in reraise
raise value.with_traceback(tb)
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 1322, in getresponse
response.begin()
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 303, in begin
version, status, reason = self._read_status()
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 264, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/Lase.Adebayo/PycharmProjects/eBay Data Collector/eBayCaller/ebay scripts/ebayxml.py", line 24, in <module>
resp = api.execute('findItemsByKeywords', request).dict() # Change from XML to dictionary
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ebaysdk\connection.py", line 123, in execute
self.execute_request()
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ebaysdk\connection.py", line 189, in execute_request
self.response = self.session.send(self.request,
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Lase.Adebayo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
相同的代码大约在两周前工作。
解决方案
似乎 python sdk 开发人员尚未将代码从 HTTP 更改为 HTTPS。您可以使用 YAML 配置文件来指定 https 请求。
svcs.ebay.com:
appid: YOUR_APP_ID
https: 1
推荐阅读
- unix - 如何在unix中读取文本文件的第n行和第m个字段
- java - 单击android中的按钮时如何验证recyclerView项目
- python-3.x - 根据另一列的值(时间)返回熊猫(python)中列的值
- java - 当 GWT Web 应用程序在 linux 服务器上运行时,我有这样的错误
- c# - 无法使用 LINQ 比较两个列表
- ios - 如何使用 FIT C++ 库构建 iOS 框架
- python - 有人可以解释逻辑和布尔之间的区别吗?在这种情况下,
- sql - 在 SQL 查询中使用 Not in
- reactjs - 使用 react + Vertx 上传文件
- javascript - 如何观察我的 DOM 的变化并用 jQuery 对它们做出反应?