Would you like to find out the secondhand prices, get information on auctions, or know what products are popular? With the help of eBay product data, you will learn about the goods that are available and their changes in the marketplace. Using Python, you can create a spreadsheet based on the listings rather than writing them down manually.
In this tutorial, we will demonstrate how you can scrape eBay using Requests and BeautifulSoup in Python, including how to extract product title and price, deal with pagination, and create a CSV file, making extracting product data simple.
Note: eBay's User Agreement prohibits automated access using scrapers without eBay's prior express permission. The HTML examples below are for learning, analyzing saved pages, or accessing eBay pages only when you have that permission. Public visibility does not automatically grant permission to collect public data programmatically. For an approved integration, consider eBay's Browse API.
How to scrape eBay product listings using Python
The basic structure of an eBay scraper includes a number of steps: creating a search URL, getting the HTML, finding the listing elements, extracting the data, and saving the information. The critical point is which fields will be available on the search page and which will need to open a specific item.
In this article, you should have Python 3.9 or higher installed, a code editor, and the requests and BeautifulSoup modules. Before scraping eBay, figure out which fields you really need and do you have permission to scrape them. Install the packages with:
pip install requests beautifulsoup4
No browser automation is needed for information already present in the downloaded HTML. However, scraping eBay gets more complicated when a field loads via JavaScript, changes between item types, or isn't available to your session.
Step 1: Identify the target URL
Start with a product search on eBay. For example, searching for vintage cameras produces a URL similar to:
https://www.ebay.com/sch/i.html?_nkw=vintage+camera
The nkw parameter contains your search keyword. A second parameter, pgn, commonly selects the page number. That gives you a starting point for collecting search results spanning multiple pages.
Instead of manually encoding spaces and other characters, let Requests handle the encoding of the parameters:
SEARCH_URL = "https://www.ebay.com/sch/i.html"
params = {"_nkw": "vintage camera", "_pgn": 1}
Open the selected page in a browser and analyze its code using Developer Tools. Find repeated listing cards as well as links in them. Note that filtered results on eBay can vary depending on your location, product type, sorting, and availability.
Step 2: Send an HTTP request with headers
Requests downloads the page, and headers indicate the client and preferred language. In the case of an allowed collection, start with just one single request and not several at once.
import requests
headers = {
"User-Agent": "ProductResearchExample/1.0 (contact: [email protected])",
"Accept-Language": "en-US,en;q=0.9",
}
response = requests.get(
SEARCH_URL, params=params, headers=headers, timeout=20
)
response.raise_for_status()
html = response.text
The timeout ensures that your script does not hang forever. The raise_for_status() statement throws an exception if the server responds with an unsuccessful HTTP status code. In case of 403, 429, or the verification page, you should stop here and check your permissions instead of finding ways to bypass it.
For scraping sites like eBay with their consent, it is much better to introduce yourself honestly than disguise yourself as someone else. We will return to headers, proxies, and rate limits later.
Step 3: Parse the HTML and find listing cards
BeautifulSoup turns raw HTML into a structure you may navigate with CSS selectors. Traditional eBay search markup has used li.s-item containers, but this is an illustrative selector, not a permanent contract.
from bs4 import BeautifulSoup
soup = BeautifulSoup(html, "html.parser")
cards = soup.select("li.s-item")
print(f"Found {len(cards)} potential cards")
Use your browser's inspector to confirm the element names on the page you are allowed to analyze. For eBay scraping, saving a representative HTML file first makes selector testing much easier.
Some cards are promoted, decorative, or missing information. A reliable eBay web scraper should validate a card before storing it, rather than assuming every matching element represents a usable product.
In case the count is zero, check the answer body itself. It can be formatted differently, show an error message, or represent a page that requires the use of JavaScript.
Step 4: Extract product titles, prices, bids, and links
Each listing card can contain several useful fields. The title identifies the item, while the displayed price might be a fixed amount, an auction value, or even a range. A dedicated eBay price scraper should preserve the currency and raw price text until those differences can be normalized.
Try these selectors against an inspected HTML sample:
def read_text(card, selector):
element = card.select_one(selector)
return element.get_text(" ", strip=True) if element else ""
for card in cards[:3]:
title = read_text(card, ".s-item__title")
price = read_text(card, ".s-item__price")
bids = read_text(card, ".s-item__bids")
link = card.select_one("a.s-item__link[href]")
print(title, price, bids, link.get("href") if link else "")
The number of bids is included only when the offer is an auction type; blank does not signify a value of zero. The absence of a title or a product URL is one of the reasons for discarding the offer. Store the URL so that you can refer to the source of each offer as well as validate the values obtained later on.
This first pass is enough for a lightweight eBay listing scraper. But accurate product data extraction requires understanding what the search card doesn't show.
Step 5: Add category, shipping, variants, and seller information
Shipping costs, product condition, seller information snippets, and geographical locations can all be found on the search cards. The category of a product, along with the available sizes or colors, sometimes requires the use of the detail page. Collecting information solely from the search cards will not yield all the necessary information.
Listing category
Inspect breadcrumb links on the individual listing. Depending on the layout, a selector such as nav[aria-label*="breadcrumb"] a may reveal the hierarchy. Record the full path when present, because a camera accessory and a camera body shouldn't automatically land in the same group.
Shipping information
Try .s-item__shipping or .s-item__logisticsCost on the card. Shipping may depend on the destination, and a phrase such as "Free shipping" is different from missing information. Store the displayed text, not an assumed cost.
Listing variant data
Sizes, colors, and other choices may appear in dropdowns on an item page. Inspect <select> elements and their <option> values. A default prompt such as "Select size" isn't an actual variant. Some configurations require interaction or are represented in script data instead, so BeautifulSoup may not reveal every option.
Seller information
Some cards expose .s-item__seller-info-text. A listing page may also contain a seller section. Keep only seller details necessary for your research, such as a public shop name or visible rating. Avoid collecting contact details or personal information.
For each page scrape on eBay, the traffic is going to increase. Make these visits optional and limit them. In case you need all information about product variations, eBay's Browse API offers item and item group resources which can be better than flaky HTML selectors.
Step 6: Handle search results and pagination
The first screen rarely contains everything relevant to your search keyword. Pagination allows an eBay scraper to read additional search results, provided your authorization covers that access.
With respect to the traditional URL, increase _pgn by 1 from 2 onwards. It is important to note that there is no guarantee that the same product will not appear again as a duplicate owing to sponsored products, changes in rank, and overlap in queries.
Set a small MAX_PAGES value, and stop when a page provides no usable new items. For production research, also record a collection timestamp so you can distinguish a historical price from a current one.
Since eBay results may change while you work, pagination isn't a guaranteed snapshot of the entire marketplace. This matters when scraping eBay for trend analysis instead of a quick product lookup.
Step 7: Save the records to CSV or Excel
Once you've gathered the fields, save them in a tabular format. Python's built-in csv module is sufficient for a file that opens in Excel, Google Sheets, or another spreadsheet app.
import csv
with open("ebay_products.csv", "w", newline="", encoding="utf-8-sig") as f:
writer = csv.DictWriter(
f, fieldnames=["title", "price", "bids", "url"], extrasaction="ignore"
)
writer.writeheader()
writer.writerows(records)
Here, records is a list of dictionaries containing those fields; extra keys are ignored in this small example. You can extract data for additional columns simply by expanding the fieldnames list.
The utf-8-sig encoding makes special characters more compatible with many Excel installations. If you need a native .xlsx file, load your records into pandas and use to_excel() after installing openpyxl.
Prior to any analysis, normalizing price ranges, currencies, and shipping costs is necessary. A $40 product that incurs a shipping cost of $20 is not necessarily more affordable than a $50 product with free shipping. The original text should be maintained in order to avoid errors in the extraction process.
Step 8: Put it together - full Python code
The example below contains request-making, parsing, deduping, option to examine details page, and exporting to CSV file. It has default settings that are not aggressive and it stops on restricted answers. Run the network part only with explicit permission from eBay; otherwise, you should work with saved HTML.
import csv
import time
from datetime import datetime, timezone
from urllib.parse import urljoin
import requests
from bs4 import BeautifulSoup
SEARCH_URL = "https://www.ebay.com/sch/i.html"
KEYWORD = "vintage camera"
MAX_PAGES = 2
DETAIL_LIMIT = 3
DELAY_SECONDS = 3
FIELDS = ["title", "price", "bids", "url", "shipping",
"seller", "category", "variants", "collected_at"]
session = requests.Session()
session.headers.update({
"User-Agent": "ProductResearchExample/1.0 (contact: [email protected])",
"Accept-Language": "en-US,en;q=0.9",
})
def text(root, selector):
node = root.select_one(selector)
return node.get_text(" ", strip=True) if node else ""
def get_soup(url, params=None):
response = session.get(url, params=params, timeout=20)
if response.status_code in (403, 429):
raise RuntimeError(f"Access restricted: HTTP {response.status_code}")
response.raise_for_status()
if "captcha" in response.url.lower() or "pardon our interruption" in response.text.lower():
raise RuntimeError("Verification page received; stop requests")
return BeautifulSoup(response.text, "html.parser")
def parse_card(card):
a = card.select_one("a.s-item__link[href]")
title = text(card, ".s-item__title")
if not a or not title or title.lower().startswith("shop on ebay"):
return None
url = urljoin("https://www.ebay.com", a["href"]).split("?")[0]
return {
"title": title,
"price": text(card, ".s-item__price"),
"bids": text(card, ".s-item__bids"),
"url": url,
"shipping": text(card, ".s-item__shipping, .s-item__logisticsCost"),
"seller": text(card, ".s-item__seller-info-text"),
"category": "",
"variants": "",
"collected_at": datetime.now(timezone.utc).isoformat(),
}
def add_details(item):
soup = get_soup(item["url"])
crumbs = [a.get_text(" ", strip=True) for a in
soup.select('nav[aria-label*="breadcrumb"] a')]
if crumbs:
item["category"] = " > ".join(crumbs)
if not item["seller"]:
item["seller"] = text(soup, ".ux-seller-section__item--seller a")
options = []
for select in soup.select("select"):
label = select.get("aria-label") or select.get("name") or "Variant"
values = [o.get_text(" ", strip=True) for o in select.select("option")
if o.get("value") and o.get("value") != "-1"]
if values:
options.append(f"{label}: {', '.join(values)}")
item["variants"] = " | ".join(options)
records = []
seen = set()
for page in range(1, MAX_PAGES + 1):
if page > 1:
time.sleep(DELAY_SECONDS)
soup = get_soup(SEARCH_URL, {"_nkw": KEYWORD, "_pgn": page})
new_items = 0
for card in soup.select("li.s-item"):
item = parse_card(card)
if not item or item["url"] in seen:
continue
seen.add(item["url"])
records.append(item)
new_items += 1
if new_items == 0:
break
for item in records[:DETAIL_LIMIT]:
time.sleep(DELAY_SECONDS)
add_details(item)
with open("ebay_products.csv", "w", newline="", encoding="utf-8-sig") as f:
writer = csv.DictWriter(f, fieldnames=FIELDS)
writer.writeheader()
writer.writerows(records)
print(f"Saved {len(records)} listings to ebay_products.csv")
The full example for an eBay scraper does not try to parse price and bid strings because doing so prematurely might eliminate meaningful information. Categories and variants are not parsed from the HTML when no information is available because it is better to create an incorrect record than a meaningless one.
In order to have a more controlled environment for testing on a local machine, save the example response as sample_ebay.html and parse the cards in it using BeautifulSoup(open("sample_ebay.html", encoding="utf-8").read(), "html.parser") and then feed them into parse_card() before any real requests.
Scrape eBay Product Data With Python in 2026
Start scrapingHow to avoid getting blocked
Request restrictions are often encountered when dealing with traffic control, account security, or site policy enforcement. An eBay crawler needs to take account of such limitations rather than breaking them down. These rules refer to sites that can be accessed with the permission of eBay.
Use proxies carefully
A proxy sends your requests via an additional IP address. While it is useful in order to test regional displays that you are allowed to see, it will not enable you to scrape information from eBay without permission.
Residential proxies are usually better suited for regional testing, whereas data center proxies might be better suited for simple infrastructure purposes.
For instance, in a Requests session, you can use the MarsProxies endpoint:
proxy_url = "http://USERNAME:PASSWORD@HOST:PORT"
session.proxies.update({"http": proxy_url, "https": proxy_url})
Enter the values that you get from the proxy dashboard. Do not use any passwords in a publicly accessible repository. Do not assume that the proxies will allow you to scrape eBay. IP rotation is not the solution when eBay denies permission to scrape, gives you a CAPTCHA, or blocks you.
Rotate User-Agent strings only when appropriate
User-Agent is an identifier of the application making the request. It may be tempting for some people to quickly switch the identity of the browser. However, a legitimate collector may find it better to stick with honesty in the identification.
In case you have an experiment that involves different renders in the approved clients, use the right header explicitly.
In the common eBay data extraction process, one identifying User-Agent is enough. The difference between the page content and your header should be treated as an error, not an opportunity for disguise.
Throttle requests
Pace is made consistent when you slow down. Introduce delays before fetching pages that are permitted, caching the pages collected, and reusing the Requests session. Begin with a small number of items and then expand your dataset.
If you get a 429 Too Many Requests status code, it indicates that you have hit your limit. The proper approach for eBay scraping is to treat the status code as an indication that scraping should stop.
Respect the Retry-After header if one is provided, pause your scraping job, and check whether additional requests are possible.
Avoid scraping too fast or in bulk
Scraping on eBay is technically challenging and governed by its terms. Narrow down your category selection, get only the fields required by the project, and de-duplicate URLs before going further. Scraping the same data again is simply a waste of bandwidth and creates discrepancies.
In case you need ongoing scraping, you can try the official API. The API might provide more consistent fields along with access options. No eBay scraper guarantees uninterrupted access to the HTML structure that could be changed or blocked.
Common challenges and how to fix them
Even a carefully written script can run into problems. These are the most common issues when scraping eBay, along with practical ways to diagnose each one.
HTML structure changes frequently
Selectors such as .s-item__price describe a particular layout, not a guaranteed interface. eBay pages can vary by country, product type, and experiment. A redesign may cause your script to produce blank prices while still returning a successful HTTP status.
Keep a small test file in HTML format and review the fields each time a code modification occurs. This allows you to extract information from existing samples without making new requests to the website. In case the number of parsed cards is drastically reduced, analyze the answer and update only the broken selectors.
Elements are loaded dynamically
The Requests library will return the server response, but it won’t run any JavaScript code. In case the data related to sellers, variations, or estimated shipping costs is loaded when the web page opens, you should check that this data is available in the HTML file.
If scraping on such web pages is allowed by a web browser, you can use the Playwright library. In other cases, you need to refer to the structured response in the Browse API. Remember that having a headless browser does not give you the right to scrape eBay pages.
CAPTCHAs and verification pages
A CAPTCHA shows that the provider requires verification or restricts access. This may also be a sign that your eBay scraper does not receive any regular listing page at all. Please verify the HTTP response and the page title instead of trying to parse a challenge page.
In case of a verification requirement, you have to stop automated requests. You should not try to complete or evade the challenge by using proxy rotation or other techniques.
Rate limits and temporary errors
429 error means too many requests. 403 error means that you have forbidden access. 5xx temporary errors could be distinct from these errors: in case of allowed integration, several retries with backoff would work better if the server is unavailable.
Create logs with status codes, timestamp, and URL requested. This will allow determining if you could not scrape eBay due to bugs in the parsing library, temporary problems, or because of access limitations. Do not use retries infinitely and do not ignore refusals.
Real-world use cases for eBay scraping
Once your data is consistent, even a small sample can reveal useful patterns. Here are three common applications for eBay product data, along with a review of what the numbers can and cannot tell you.
Price monitoring
A comparison of asking prices will help both retailers and collectors analyze the movement in the market. There could be a price-tracking script for recording the asking prices at different times in a legitimate process, while a spreadsheet will make changes visible on the basis of item, condition, and vendor.
For comparative analysis to be effective, it is important to distinguish between bid prices and selling prices. Failure to classify the type of auction in price comparison will lead to inaccurate results. Shipping cost, currency, condition of the product, and date of listing should be taken into consideration.
Product comparison tools
A shopping analysis software enables similar products to be grouped together. Users could compare camera lenses based on brand, condition, shipping options, and cost. By extracting information in a structured format, it is less cumbersome to filter than looking through a large number of webpages.
It is all about comparison of likes with likes. The prices for a "body only" camera cannot be compared to those for a package deal which includes lenses and other accessories. This is also important when it comes to variation; the seller may offer different sizes and setups with one price tag.
Market research
The market researchers analyze the number and variety of auctions listed on eBay to identify supply patterns, category popularity, and strategy. Examination of publicly available information can serve to formulate questions like what types of products have the broadest range of prices or which descriptions are typical for a certain niche.
However, search results can be ranked and personalized, and they are not the full statistical sample of all available inventory. The researcher who scrapes eBay for market research needs to keep records of keywords, filters used, marketplace, sampling methods, and dates.
Final Thoughts
Scraping eBay shows how several simple Python libraries allow turning HTML of a chaotic online market into structured information. This is easy to do: pick up a search, retrieve allowed pages, scrape the data, deal with empty fields, and store the results in a spreadsheet.
Only when you have all the necessary permissions will you be able to scrape eBay. And the tricky thing here is to keep doing it legally despite all the changes.
It all begins with either a saved HTML file or an allowed test, followed by scaling within the scope of your permissions. For commercial use of eBay product data, make sure to try the API first. For cases where proxies are appropriate for legal regional testing, we are ready to provide you with the tools needed to manage the connections.
FAQ
Is it legal to scrape data from eBay?
It really depends on the situation and relevant laws. In eBay’s User Agreement, scraping is not allowed without prior permission, even if the data is visible to everyone. Make sure to check this and get permission.
Is it easy to scrape eBay?
Basic HTML parsing is easy to learn with Python and BeautifulSoup. Building a reliable eBay scraper is harder because page layouts, dynamic fields, permissions, and access restrictions can change.
Does eBay block scrapers?
Yes. eBay will restrict its automated traffic, show verification screens, and lock out the user from their site. In case you experience any form of restriction on eBay scrapers, stop and try another way.
What is the best tool for scraping eBay?
For permitted HTML analysis, Python Requests and BeautifulSoup are a simple starting point. For a production integration, eBay's Browse API is generally a better choice because it offers structured listing and item data.
Is there an official eBay API?
Yes. Keyword search and item detail functionality are available via the eBay Browse API through its authenticated endpoints. You will require developer credentials and an application access token to make use of the API.