Amazon Sponsored Products a Mess? Grow Sales, Lower ACoS & Simplify Campaigns with Ignite!  
Learn More



Create an ASP page, inserting the ASP code below at the very start of the page. You will need to create a database table to hold the results (see below) and enter a valid connection string in the variable indicated.

Insert the HTML code below between the <body> tags of your ASP page. To use the page run a search as normal, then paste the source code into the large box on the page and click submit.

Use the SQL code to create queries in your database which aggregate the data you have extracted.

Please note the following:

  • No warranties or guarantees are offered for this code. It has been tested and used by us, but your system settings, eBay changes, and other factors may stop it working for you.
  • You use this code at your own risk. We are not responsible for any damage or complaint arising from its use.
  • You may freely use and adapt this code for any purpose, as you see fit. Please credit this site if you do so.

ASP Code

  'First you will need a database table with the structure below,
  'or equivalent
  'CREATE TABLE [tblEbayItems] (
  '[ItemID] [int] IDENTITY (1, 1) NOT NULL ,
  '[TopCatID] [int] NOT NULL ,
  '[eBayItemID] [nchar] (10) NOT NULL ,
  '[ItemTitle] [nvarchar] (50) NOT NULL ,
  '[Price] [money] NOT NULL ,
  '[Bids] [smallint] NOT NULL)
  Dim strResponse, Match, Matches, strOutPut, intCategory
  Dim intItemCount, x, strSQL, con, strDBConnection, reItem
  Dim intMaxItems

  'Set the variable strDBConnection to connect to your database

  'Check if the form has been submitted
  If Request.Form <> "" Then

    'Gather the data submitted in the form
    intCategory = CLng(Request.Form("cat"))
    strResponse = Request.Form("text")
    intMaxItems = CInt( "0" & Request.Form("max"))
    If intMaxItems = 0 Then intMaxItems = 100
    'Set up regular expression object
    'The reItem object matches the item data embedded in 
    'JavaScript in the search results page
    'The following place holders are used:
    '$1 = Number of bids
    '$2 = eBay Item Number
    '$3 = Item Name
    '$4 = Price
    'Note that this regular expression sometimes misses data
    'so check the "Items Retrieved" number after parsing
    Set reItem = New RegExp
    reItem.Global = True
    reItem.IgnoreCase = True
    reItem.Pattern = "dSI\([01]\,[01]\,[01]\,[01]\,[01]\," & _ 
      "[01]\,[01]\,[01]\,[01]\,[01]\,[01]\,(\d{1,3})\,(\d" & _
    'Initialise the database connection
    Set con = Server.CreateObject("ADODB.Connection")
    con.Open strDBConnection
    'Uncomment the next two lines below to clear the database
    'table before adding data
    'strSQL = "TRUNCATE TABLE tblEbayItems;"
    'con.Execute strSQL
    'Execute the regular expression then iterate through the
    'resulting matches up to the maximum number of items 
    'Add the data in the placeholders to an HTML
    'table and execute a SQL query to add it to the database
    Set Matches = reItem.Execute(strResponse)
      For Each Match in Matches
        strOutPut = strOutPut & reItem.Replace(Match.Value, _
          "<tr> <td>$1</td> <td>$2</td> <td>$3</td> <td>" & _
          "$4</td> </tr>" & vbNewLine)
        strSQL = reItem.Replace(Match.Value, "INSERT INTO" & _
          "tblEbayItems (TopCatID, eBayItemID, ItemTitle," & _
          " Price, Bids) VALUES (" & intCategory & ", '$2" & _
          "', '$3', $4, $1);")  
        con.Execute strSQL
        intItemCount = intItemCount + 1
        If intItemCount >= intMaxItems Then Exit For
    Set con = Nothing  
  End If	


  <form action="" method="post" name="form">
<select name="cat">
<option value="20081" selected>Antiques</option>
<option value="550">Art</option>
<option value="267">Books</option>
<option value="12576">Business & Industrial</option>
<option value="11450">Clothing, Shoes & Accessories</option>
<option value="11116">Coins</option>
<option value="1">Collectibles</option>
<option value="293">Computers & Electronics</option>
<option value="237">Dolls & Bears</option>
<option value="45099">Entertainment</option>
<option value="11700">Home</option>
<option value="281">Jewelry & Watches</option>
<option value="619">Musical Instruments</option>
<option value="870">Pottery & Glass</option>
<option value="888">Sports</option>
<option value="260">Stamps</option>
<option value="220">Toys & Hobbies</option>
<option value="99">Everything Else</option>
</select> Category Number = <%=intCategory%>
<p>Max Items: <input name="max" type="text" value="<%=intMaxItems%>" size="5" maxlength="5"></p>
<p>Items Retrieved: <%=intItemCount%></p>
<p><input type="submit" name="Submit" value="Submit"></p>
<p><textarea name="text" cols="100" rows="25" wrap="virtual"> <%=strResponse%></textarea></p>
<td>EBAY NO</td>
<td>ITEM NAME</td>

SQL Code

This counts the number of items which received different bid volumes from zero upwards:

   SELECT Bids, COUNT(ItemID) AS BidCount
   FROM tblEbayItems
   GROUP BY Bids
   ORDER BY Bids

2nd Office