Skip to content

thunderbit-operations/ebay-scraper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eBay Scraper

A small, dependency-light Python tool to scrape eBay search listings to CSV, JSON, or JSONL — from the command line or as a Python library.

Features

  • Scrape eBay search results by keyword (e.g. laptop, vintage camera).
  • Extracts title, price, condition, item URL, seller, seller feedback, sold count, and watchers (the last few when eBay shows them on the card).
  • Targets eBay's current li.s-card layout (the legacy s-item selector no longer works).
  • Outputs CSV / JSON / JSONL, to stdout or a file.
  • Maintains a cookie session and uses browser-like headers + randomized delays to behave politely.
  • Zero heavy dependencies: just requests + beautifulsoup4.

Installation

pip install ebay-listings-scraper

Or from source:

git clone https://github.com/thunderbit-operations/ebay-scraper.git
cd ebay-scraper
pip install -e .

Quick Start

# Scrape the first page of "laptop" results to CSV (stdout)
ebay "laptop"

# Two pages, JSON, to a file
ebay "vintage camera" --pages 2 --format json --output cameras.json

# Just count results
ebay "mechanical keyboard" --count

CLI Reference

ebay QUERY [options]

Positional:
  QUERY                 Search query, e.g. "laptop" or "vintage camera".

Options:
  -p, --pages N         Number of result pages to scrape (default: 1).
  -f, --format FMT      Output format: csv | json | jsonl (default: csv).
  -o, --output PATH     Output file path (default: stdout).
  --count               Only print the number of listings found.
  --min-delay SECONDS   Minimum delay between requests (default: 2.0).
  --max-delay SECONDS   Maximum delay between requests (default: 5.0).

The ebay-listings-scraper command is installed as an alias for ebay.

Python API

from ebay_scraper import EbayScraper, scrape

# Quick helper -> list of dicts
rows = scrape("laptop", pages=1)
print(rows[0])

# Full control
scraper = EbayScraper(delay_range=(2.0, 5.0))
listings = scraper.search("vintage camera", pages=2)
for l in listings:
    print(l.title, l.price, l.condition, l.url)

# Parse saved HTML offline (no network)
html = open("search.html", encoding="utf-8").read()
listings = EbayScraper.parse(html)

Each listing exposes: title, price, condition, url, seller, seller_feedback, sold, watchers, plus .as_dict().

How it works

  1. The scraper first issues a GET https://www.ebay.com/ to collect eBay's anti-bot cookies. Without this warm-up, search pages start returning HTTP 403 after the first request.
  2. It then fetches https://www.ebay.com/sch/i.html?_nkw={query}&_pgn={page} using the same requests.Session, full Chrome-like headers, and Referer: https://www.ebay.com/.
  3. Results are parsed with BeautifulSoup. Each product is a li.s-card; the title is in .s-card__title .su-styled-text, the price in .su-styled-text--emphasis, condition in the first segment of .s-card__subtitle, and seller feedback / sold count are read from the card text. The leading "Shop on eBay" placeholder ad card is skipped.
  4. Requests are spaced out by a randomized delay (default 2–5 s).

Limitations

Be honest about what this is: a lightweight, best-effort scraper, not an enterprise data pipeline.

  • It relies on cookie + IP reputation. A single residential/clean IP works for light use, but scraping many pages or running it frequently will get throttled or 403'd. For large-scale scraping you need to rotate IPs / proxies yourself — this tool does not do that.
  • No login, no CAPTCHA solving. If eBay serves an interstitial or challenge page, the scraper will simply return no listings.
  • Selectors can break. eBay changes its markup periodically (this tool already had to migrate from s-item to s-card). When the layout changes, the selectors in ebay_scraper/scraper.py will need updating.
  • Search cards only. It reads what's on the search results page. Some fields (seller name, watchers) are not always present on the card and will be None. It does not visit individual item pages.
  • Respect eBay's Terms of Service and robots.txt, and only scrape data you are permitted to access.

💡 Don't want to write code, rotate IPs, or fix selectors when eBay changes layout? Thunderbit is an AI web scraper Chrome extension that scrapes eBay (and any site) in 2 clicks, no code.

Related tools

Legal

This project is for educational and research purposes. You are responsible for how you use it. Scraping may be subject to eBay's Terms of Service and applicable laws — review them and scrape responsibly (reasonable rate limits, only publicly accessible data).

License

MIT

About

Scrape eBay product listings (title, price, condition, seller) to CSV/JSON — Python CLI + API, no API key.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages