#!/usr/bin/env python3 """ eBay Scanner - WORKING VERSION Extracts cast iron listings from eBay search results """ import requests from bs4 import BeautifulSoup import re from datetime import datetime def search_ebay_cast_iron(): """Search eBay for cast iron items""" queries = [ "griswold skillet", "wagner cast iron", "cast iron skillet vintage", "wapak skillet" ] headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml', } all_items = [] for query in queries: url = f"https://www.ebay.com/sch/i.html?_nkw={query.replace(' ', '+')}&_sacat=0" try: response = requests.get(url, headers=headers, timeout=15) soup = BeautifulSoup(response.text, 'html.parser') # Find all divs and look for price + cast iron keywords all_divs = soup.find_all('div') for div in all_divs: text = div.text if '$' in text and any(kw in text.lower() for kw in ['skillet', 'griswold', 'wagner', 'cast iron', 'wapak']): # Extract price price_match = re.search(r'\$([\d,]+\.?\d*)', text) price = float(price_match.group(1).replace(',', '')) if price_match else 0 # Extract title (first 150 chars) title = text.strip().replace('\n', ' ')[:150] # Find link link_elem = div.find('a', href=True) link = link_elem['href'] if link_elem else '' if price > 0 and title and len(title) > 10: all_items.append({ 'title': title, 'price': price, 'link': link if link.startswith('http') else f'https://www.ebay.com{link}', 'source': 'eBay', 'found_at': datetime.now().isoformat() }) except Exception as e: print(f"Error scanning {query}: {e}") # Remove duplicates by title seen = set() unique_items = [] for item in all_items: if item['title'] not in seen: seen.add(item['title']) unique_items.append(item) return unique_items if __name__ == "__main__": print("🔍 Scanning eBay for cast iron...") items = search_ebay_cast_iron() print(f"Found {len(items)} unique items") for item in items[:10]: print(f" - {item['title'][:60]} - ${item['price']}")