timotheus / ebaysdk-python

eBay API SDK for Python
https://developer.ebay.com/tools/sdks
Other
809 stars 326 forks source link

issue with findCompletedItems #293

Closed alexb2123 closed 4 years ago

alexb2123 commented 4 years ago

I am not sure if this is an appropriate place to pose this question. If it's not, I apologize.

I recently started working with the ebaysdk, specifically the findcompleteditems call.

I'm trying to loop through a pandas df and and place values in a column into a variable which is to be used as the keyword in my API call. However, my code only works when I call a single item (and not loop). When I loop the df I get an output of.

ebaysdk.exception.ConnectionError: "findCompletedItems: Internal Server Error, Domain: CoreRuntime, Severity: Error, errorId: 5014, Error reading from XML stream: Unexpected character ' ' (code 32); expected a semi-colon after the reference for entity 'M'\n at javax.xml.stream.SerializableLocation@4eb74eb7"

This is my code:

from ebaysdk.finding import Connection as finding
from bs4 import BeautifulSoup
import pandas as pd
import traceback

ID_APP = 'asljkdhak-LastSold-PRD-33882c1d0-aad65283'
df = pd.read_excel(open('/Users/asjkdhasjdhDownloads/snacks-3.xlsx', 'rb'), sheet_name='Sheet2', usecols='B')
Keywords = df
#Keywords = 'candy'

api = finding(appid=ID_APP, config_file=None)
solditemsonly = True
listingtype = 'FixedPrice'
condition = 'New'
locatedin = 'US'

dct_completedrequest = {
    'keywords': Keywords,
    'itemFilter': [
        {'name': 'Condition', 'value': condition},
        {'name': 'SoldItemsOnly', 'value': solditemsonly},
        {'name': 'ListingType', 'value': listingtype},
        {'name': 'LocatedIn', 'value': locatedin},
    ]}

response = api.execute('findCompletedItems', dct_completedrequest)
soup = BeautifulSoup(response.content, 'lxml')
items = soup.find_all('item')

for item in items:
    cat = item.categoryname.string.lower()
    title = item.title.string.lower()
    price = int(round(float(item.currentprice.string)))
    url = item.viewitemurl.string.lower()

    print('________')
    print('cat:\n' + cat + '\n')
    print('title:\n' + title + '\n')
    print('price:\n' + str(price) + '\n')
    print('url:\n' + url + '\n')
    input()
hellfire989 commented 6 months ago

@alexb2123 What was the solution to this issue? I'm getting the same problem