skip to Main Content

I got a basic script to connect with ebay API and search for keyword items. The script works fine, but unfortunatelly, it searches only the first 100 items, how to increase amount of the search results ?

from ebaysdk.finding import Connection as finding
from bs4 import BeautifulSoup

Keywords = 'Ford'
api = finding(appid='APP ID', config_file=None)
api_request = { 'keywords': Keywords, 'outputSelector': 'SellerInfo' }

response = api.execute('findItemsByKeywords', api_request)
soup=BeautifulSoup(response.content, 'lxml')
totalentries = int(soup.find('totalentries').text)
items= soup.find_all('item')

I finally sorted this one out. The paginationInput is actually a dictionary in it self, which was a bit messing with me. Also for some reason it’s more useful to use findItemsAdvanced instead of findItemsByKeywords .

Keywords = product
    api = finding(appid='APP_ID', config_file=None)
    api_request = { 'keywords': product,'outputSelector': 'SellerInfo' ,  'categoryId': ['33034'],  'paginationInput':{'entriesPerPage':100, 'pageNumber':1} }


    response = api.execute('findItemsAdvanced', api_request)
    soup=BeautifulSoup(response.content, 'lxml')

2

Answers


  1. Ebay is probably paginating, that means that they are splitting their response by a number of entries for each page.

    Their response to a query should have the current page number and the total number of pages, you will need to request all the following pages you are interested in.

    Login or Signup to reply.
  2. This is documented on the page for findItemsByKeywords.

    Add a paginationInput.pageNumber parameter to your API request parameters, maybe something like

    from ebaysdk.finding import Connection
    from bs4 import BeautifulSoup
    
    Keywords = "Ford"
    api = Connection(appid="APP ID", config_file=None)
    
    items = []
    
    for page in range(1, 11):
        api_request = {
            "keywords": Keywords,
            "outputSelector": "SellerInfo",
            "paginationInput.pageNumber": page,
        }
        response = api.execute("findItemsByKeywords", api_request)
        soup = BeautifulSoup(response.content, "lxml")
        totalentries = int(soup.find("totalentries").text)
        items.extend(soup.find_all("item"))
    
    print(items)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search