eBay is the most popular secondhand marketplace in the US, most of its users are US-based making it an important platform to harvest data and learn about the US resale market.
Any business that operates on eBay knows how important it is to stay ahead of competition and trends in 2025. One way this can be done is by leveraging publicly available data those platforms have to offer. Data which can be used to gain insight into markets, such as learning about buying trends from buyers and pricing trends from competitors.
Knowing which item is getting sold in high quantities on a daily basis, price hikes from resellers and product supply and demand are all information that can be analyzed and used in multiple ways.
Let’s have a look at a few ways resellers benefit from eBay sales data and how we can scrape eBay using ScrapingAnt’s Python API.
How Resellers can Benefit from eBay Sales Data
eBay sales data can be leveraged in multiple ways either to make more money or to save money, let's have a look at a few of them.
Finding Market Gaps
Resellers can learn about markets is key in order to find gaps in them, filling those market gaps is one of the most profitable sales strategies for resellers.
Such as finding a product that’s in high demand but has low supply, a product that’s underpriced or an underserved market niche.
Finding Low Competition Markets
Most of the product categories on eBay are highly competitive, web scraping can help in revealing a less saturated niche.
One way this can be done is by analyzing the number of sellers in relation to the number of buyers in a given category.
Finding Rare or Discontinued Products
Rare products gain value or item since they’re hard to find, web scraping can help track product categories with increased prices over time.
A product that is consistently sold above its retail price is a signal that can be used by resellers to source that item at a lower price and sell it for higher.
How to Scrape eBay with ScrapingAnt Python API
Let's see how we can easily scrape eBay product listings using ScrapingAnt's Web Scraping API in Python.
In this simple example we will be extracting the title and the price of product listings on eBay.
Let's jump right in!
Getting our Python Web Scraping API
Now let’s have a look at how we can scrape eBay product listings using ScrapingAnt’s Python API. First make sure to have created a ScrapingAnt account here.
We will then need our API token, you can access that by going on the ScrapingAnt Admin Panel and click on the Web Scraping API tab on the left side.
For this example, we’ll just need the Python code snippet in the bottom right:
Coding our Web Scraper in Python
First, let’s import the libraries we’ll be using.
import http.client
from bs4 import BeautifulSoup
Now let's add our GET request we copied earlier.
We will replace the example URL in the conn.request()
function with eBay’s URL for search. We’ll also add the .format()
method at the end of the URL string and a string placeholder within the string to search for a given keyword, this will make it easier for searching different products.
The code that we will use to query the Web Scraping API should look like this:
query = 'MacBook'
conn = http.client.HTTPSConnection("api.scrapingant.com")
conn.request("GET", "/v2/general?url=https://www.ebay.com/sch/i.html?_nkw={0}&x-api-key=YOUR-API-TOKEN".format(query))
res = conn.getresponse()
data = res.read()
Notice the variable called query
, you can replace the string 'MacBook'
with whatever you want to scrape from eBay.
For this example, let’s use 'MacBook'
.
Now, let’s parse the HTML we will be scraping using BeautifulSoup:
soup = BeautifulSoup(data, 'html.parser')
Now that we’ve extracted and parsed the HTML from eBay’s search, we’ll have to find the HTML tags for the title and price of eBay’s product listings.
This can easily be done by “Inspecting” the page in all major browsers, we’ll be using Google Chrome:
Here's the HTML tag for the title which is div.s-item__title
:
And here's the HTML tag for the price which is span.s-item__price
:
Now let's locate those elements using BeautifulSoup and instantiate their values to our variables titles
and prices
:
titles = soup.find_all('div', class_='s-item__title')
prices = soup.find_all('span', class_='s-item__price')
Now let's make our script print out the what we've scraped:
for t,p in zip(titles[2:],prices[2:]):
print(t.text,p.text)
The full code should look like this:
import http.client
from bs4 import BeautifulSoup
query = 'MacBook'
conn = http.client.HTTPSConnection("api.scrapingant.com")
conn.request("GET", "/v2/general?url=https://www.ebay.com/sch/i.html?_nkw={0}&x-api-key=YOUR-API-TOKEN".format(query))
res = conn.getresponse()
data = res.read()
soup = BeautifulSoup(data, 'html.parser')
titles = soup.find_all('div', class_='s-item__title')
prices = soup.find_all('span', class_='s-item__price')
for t,p in zip(titles[2:],prices[2:]):
print(t.text,p.text)
Now we save the code to a file called test.py
.
And we run our script in a Terminal if you're on Mac/Linux or a Windows Command Promt with python test.py
.
Here's the output of our Python script:
Conclusion
In just a few lines of Python code, we've been able to scrape the first page of eBay's product listings using ScrapingAnt's powerful Web Scraping API, and extracted the titles and prices of those products listing using BeautifulSoup.
You can access the full code on Github here.