Я получаю сообщение об ошибке подключения при попытке использовать eBay для поиска SDK с python - PullRequest
0 голосов
/ 16 апреля 2020

В последнее время, когда я пытался соединиться, чтобы делать запросы с eBay, находящим SDK с python, я получал ошибки соединения. В сообщении об ошибке не указано, что не так.

Это сценарий python, который я написал для выполнения запросов API.

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

Этот же код работал около двух недель go.

Ответы [ 3 ]

1 голос
/ 16 апреля 2020

Кажется, что python разработчикам sdk еще предстоит изменить код с HTTP на HTTPS. Вы можете использовать файл конфигурации YAML для указания запросов https.

svcs.ebay.com:
    appid: YOUR_APP_ID
    https: 1
0 голосов
/ 20 апреля 2020

Если вы не хотите использовать YAML, вы можете добавить параметр в api_call:

Например, вот код, который я использую, когда не использую YAML в Python:

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

ИЛИ вы можете установить https = 1

0 голосов
/ 17 апреля 2020

Настройка YAML необходима, если вы хотите совершать звонки через https для версии 2.1.5 SDK или более ранней версии. 2.2.0+ будет заставлять все звонки через https, так как eBay полностью перешел на https.

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

...