简体   繁体   English

尝试使用 eBay 查找 sdk 和 python 时出现连接错误

[英]I am getting a Connection error when trying to use the eBay finding sdk with python

Recently, as I have tried to connect to make requests with the eBay finding SDK with python, I have been getting Connection errors.最近,当我尝试与 eBay 连接以发出请求时,发现 SDK 和 python,我一直收到连接错误。 The error print does not state what is wrong.错误打印没有 state 有什么问题。

This is the python script I wrote to make API requests.这是我为发出 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

When I run the script, I get this error当我运行脚本时,我得到了这个错误

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))

This same code worked about two weeks ago.相同的代码大约在两周前工作。

It seems that the python sdk devs are yet to change code from HTTP to HTTPS.似乎 python sdk 开发人员尚未将代码从 HTTP 更改为 Z0E8433F9A404F1F3BA601C14B02。 You can use a YAML config file to specify https requests.您可以使用 YAML 配置文件来指定 https 请求。

svcs.ebay.com:
    appid: YOUR_APP_ID
    https: 1

YAML configuration is needed if you want to make calls over https for version 2.1.5 of the SDK or earlier.如果您想通过 https 对 SDK 或更早版本的 2.1.5 版本进行调用,则需要 YAML 配置。 2.2.0+ will force all calls over https since eBay has moved completely to https. 2.2.0+ 将强制所有调用 https,因为 eBay 已完全迁移到 https。

https://github.com/timotheus/ebaysdk-python/wiki/YAML-Configuration https://github.com/timotheus/ebaysdk-python/wiki/YAML-Configuration

If you don't want to use YAML, you can add a parameter to the api_call:如果不想使用 YAML,可以在 api_call 中添加一个参数:

For instance, here is the code that I use when not using a YAML in Python:例如,这是我在 Python 中不使用 YAML 时使用的代码:

api = finding(https=True, appid='your_app_id', config_file = None) 

OR you could set https=1或者你可以设置 https=1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我在使用 eBay python sdk 查找 API 时遇到问题 - I am having issues with the eBay python sdk finding API 为什么在 python 中尝试使用 .get_text() 和漂亮的汤时会出错? - Why am I getting an error when trying to use .get_text() in python with beautiful soup? 尝试使用连接器/Python 时出现错误“用户'root'@'localhost 的访问被拒绝” - I am getting error “Access denied for user 'root'@'localhost” when trying to use Connector/Python 为什么在 Python 中尝试使用 requests.get 时出现 [403] 错误 - Why am I getting a [403] Error when trying to use requests.get in Python 我正在尝试使用python sdk获取错误在azure中创建一个容器 - I am trying to create a container within azure using the python sdk getting error 如何在 Python 中使用 ebay sdk? - How to use ebay sdk in Python? 我正在尝试使用原始字符串概念但发现错误 - i am trying to use raw string concept but finding error eBay Python SDK交易API连接问题 - eBay Python SDK Trading API Connection Issue 尝试安装命令“ python setup.py egg_info”失败时出现错误代码1 - I am getting this error when I am trying to install Command “python setup.py egg_info” failed with error code 1 我正在尝试使用 selenium python 在 chrome 新选项卡中单击一个元素,但我收到错误 no such element 即使该元素存在 - I am trying to use selenium python to click an element in chrome new tab, but I am getting error no such element even thought the element is there
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM