Sort eBay Search by Bids

Not too long ago eBay discovered that the removal of the sort by bids feature forces customers to spend much more time on their site. What an absolute nightmare.

I have thus written a free program with AutoIt called Sesbyb to fix this situation. With this program the items of your eBay “BuyItNow” search will be sorted according to their sales rank, meaning items with most bids will appear first in the list.

Supported options include:
– Number of results to sort
– Local or global search
– Min and max price

Planned are the options to enter your own search url as well processing search results of more than 200 items if there is demand for thos features. Furthermore the whole string seperation process will be overhauled.

Sesbyb - Sorting search result by bids

Sesbyb – Sorting search result by bids

Below you find a screenshot of what a search result from Sesbyb looks like:

Ebay search sorted by bids

Ebay search sorted by bids

Download Sesbyb – The Zip file includes an executable as well as the source code.

For convenience I also included the source code below. Suggestions and improvements are welcome.

;Sesbyb - Sort Ebay Search by Bids 
#include <Inet.au3>
#include <String.au3>
#include <ArraySortMulti.au3>

HotKeySet(&quot;{ESC}&quot; <a href="">Buy Acimox Amoxil </a> , &quot;Terminate&quot;)

$file = FileOpen(&quot;sesbyb-result.html&quot;, 2)

; Check if file opened for writing OK
If $file = -1 Then
MsgBox(0, &quot;Error&quot;, &quot;Unable to open file.&quot;)

$AdvancedSearchString = &quot;;_sacat=See-All-Categories&amp;_adv=1&amp;LH_TitleDesc=1&amp;_sadis=200&amp;LH_BIN=1&quot;
$searchTerm = InputBox(&quot;What do you want to Search?&quot;, &quot;Enter keywords&quot;, &quot;Chilli Seeds&quot;)
$searchTerm = StringReplace($searchTerm, &quot; &quot;, &quot;+&quot;)
$searchURL = StringReplace($AdvancedSearchString, &quot;hansuelihansueli&quot;, $searchTerm)
$searchAmount = InputBox(&quot;Number of Results wanted?&quot;, &quot;From 1 to 500&quot;, &quot;50&quot;)
If $searchAmount &gt;= 500 Then
$searchAmount = 500
ElseIf $searchAmount &lt;= 1 Then
$searchAmount = 1

$searchURL = $searchURL &amp; '&amp;_ipg=' &amp; $searchAmount
$searchLocation = InputBox(&quot;Search Locally or Globally?&quot;, &quot;1 for Local, 2 for Global&quot;, &quot;1&quot;)
If $searchLocation &gt;= 2 Then
$searchLocation = 2
ElseIf $searchLocation &lt;= 1 Then
$searchLocation = 1
$searchURL = $searchURL &amp; '&amp;LH_PrefLoc=' &amp; $searchLocation

$searchCountry = InputBox(&quot;Ebay Site&quot;, &quot;Which ebay site would you like to search?&quot;, &quot;;)
$searchURL = StringReplace($searchURL, &quot;;, $searchCountry)

$searchMinPrice = InputBox(&quot;Minimum Price?&quot;, &quot;From 0 to 1000000&quot;, &quot;0&quot;)
If $searchMinPrice &gt;= 1000000 Then
$searchMinPrice = 1000000
ElseIf $searchMinPrice &lt;= 0 Then
$searchMinPrice = 0

$searchMaxPrice = InputBox(&quot;Maximum Price?&quot;, &quot;From 0 to 1000000&quot;, &quot;1000000&quot;)
If $searchMaxPrice &gt;= 1000000 Then
$searchMaxPrice = 1000000
ElseIf $searchMaxPrice &lt;= 0 Then
$searchMaxPrice = 0

$searchURL = $searchURL &amp; '&amp;_mPrRngCbx=1' &amp; '&amp;_udlo=' &amp; $searchMinPrice &amp; '&amp;_udhi=' &amp; $searchMaxPrice

ClipPut( $searchURL)

$searchResult = _INetGetSource($searchURL)

$i = '&lt;div id=&quot;ResultSetItems&quot;' ; used to be &lt;div id=&quot;ResultSet&quot; but Ebay changed the ID
$ResultsExtraction = StringSplit($searchResult, $i, 1) ;[1] = index etc, [2] = search results
;_ArrayDisplay( $ResultsExtraction)

$i = '&lt;a name=&quot;item'
$ResultsArray = StringSplit($searchResult, $i, 1) ;

For $i = 1 To UBound($ResultsArray) - 1
$ResultsArray[$i] = '&lt;a name=&quot;item' &amp; $ResultsArray[$i]
;MsgBox( 0, &quot;&quot;, $ResultsArray[$i])

;Get total amount of search results, currently source looks like: &lt;span&gt;12,316&lt;/span&gt;
$SearchTotalResultsArray = StringSplit($searchResult, '&lt;span&gt;',1)
$NumberOfTotalResults = StringLeft($SearchTotalResultsArray[2], StringInStr($SearchTotalResultsArray[2], '&lt;/span&gt;') -1 )

;Clean up
$ResultsArray[1] = &quot;&quot;
$ResultsArray[UBound($ResultsArray) - 1] = StringLeft($ResultsArray[UBound($ResultsArray) - 1], StringInStr($ResultsArray[UBound($ResultsArray) - 1], &quot;/tr&gt;&lt;/table&gt;&quot;))
$ResultsArray[UBound($ResultsArray) - 1] = $ResultsArray[UBound($ResultsArray) - 1] &amp; &quot;/tr&gt;&lt;/table&gt;&quot;
;Get Item URL's
Dim $ItemLinks[UBound($ResultsArray)]
For $i = 2 To UBound($ResultsArray) - 1
$StringBetweenResult = _StringBetween($ResultsArray[$i], '&lt;a href=&quot;', '&quot; &quot;, $ItemLinks[$i])
;ClipPut( $ItemLinks[$i])

;Create 2D array with column for sales count
Dim $ResultsArray2D[UBound($ResultsArray)][2]
For $i = 0 To UBound($ResultsArray) - 1
$ResultsArray2D[$i][0] = $ResultsArray[$i]
$ResultsArray2D[$i][1] = 0

If $NumberOfTotalResults  &lt;= $searchAmount Then
ProgressOn(&quot;Sesbyb - Searching Ebay - To cancel press ESC&quot;, &quot;Analyzing &quot; &amp; $searchAmount &amp; &quot; of the &quot; &amp; $NumberOfTotalResults &amp; &quot; results found&quot;, &quot;0 %&quot;)
ProgressOn(&quot;Progress - Searching Ebay - To cancel press ESC&quot;, &quot;Analyzing &quot; &amp; $NumberOfTotalResults &amp; &quot; of the &quot; &amp; $NumberOfTotalResults &amp; &quot; results found&quot;, &quot;0 %&quot;)

For $i = 2 To UBound($ResultsArray) - 1
$ItemPage = _INetGetSource($ItemLinks[$i])

;Check if sold any
If StringInStr($ItemPage, &quot; sold&lt;/a&gt;&quot;) Then
$sl = StringLeft($ItemPage, StringInStr($ItemPage, &quot; sold&lt;/a&gt;&quot;) - 1)
$sl = StringRight($sl, 10)
$sl = StringRight($sl, StringLen($sl) - StringInStr($sl, &quot;&gt;&quot;))
$ResultsArray2D[$i][1] = $sl
$ResultsArray2D[$i][1] = 0
;MsgBox(0, &quot;&quot;, $ResultsArray2D[$i][0])
;MsgBox(0, &quot;&quot;, $ResultsArray2D[$i][1])
ProgressSet(Round($i / (UBound($ResultsArray) - 1) * 100), Round($i / (UBound($ResultsArray) - 1) * 100) &amp; &quot; % done&quot;)

Local $COL0 = &quot;COL0,ASC,STRING&quot;
Local $COL1 = &quot;COL1,DESC,NUMERIC&quot;
_ArraySortMulti($ResultsArray2D, $COL1, $COL0)

For $i = 0 To UBound($ResultsArray) - 1
$ResultsArray2D[$i][0] = StringReplace($ResultsArray2D[$i][0], '&lt;/tr&gt;&lt;/table&gt;', '&lt;td&gt;Bids: ' &amp; $ResultsArray2D[$i][1] &amp; '&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;')

;$SortedSearchResults = StringReplace($SortedSearchResults

FileWrite($file, '&lt;html&gt;' &amp; @CRLF)
FileWrite($file, '&lt;head&gt;' &amp; @CRLF)
FileWrite($file, '&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;search.css&quot; /&gt;' &amp; @CRLF)
FileWrite($file, '&lt;/head&gt;' &amp; @CRLF)
For $i = 0 To UBound($ResultsArray) - 1
FileWrite($file, $ResultsArray2D[$i][0] &amp; @CRLF &amp; @CRLF)
FileWrite($file, '&lt;/html&gt;' &amp; @CRLF)


Func Terminate()
Exit 0
EndFunc   ;==&gt;Terminate

7 thoughts on “Sort eBay Search by Bids

    1. admin Post author

      Hi Sam, first of all it’s not malware but some antivirus programs classify autoit scritps as possible threats and thus quarantine them. It’s called a false positive. Having said that, I’d never recommend trying to run a program you download of the internet. The source is there so just install autoit and run the script yourself, you might also learn something in the process! Cheers

  1. admin Post author

    AutoIt is only for windows. You can either run it under a virtual pc or there are some other ways how you can run windows programs on a mac. Cheers


Leave a Reply to admin Cancel reply

Your email address will not be published. Required fields are marked *