Web DevCenter    
 Published on Web DevCenter (http://www.oreillynet.com/javascript/)
 See this if you're having trouble printing code examples


O'Reilly Book Excerpts: eBay Hacks

Hacking eBay

Related Reading

eBay Hacks
100 Industrial-Strength Tips & Tools
By David A. Karp

by David A. Karp

Editor's note: This week we're showcasing excerpts from the recently released eBay Hacks. These three hacks have a common thread--they all deal in some manner with hacking the view of eBay from your browser. In the first hack, tap into eBay's massive database right from your own address bar; in the second, learn how to use Cascading Style Sheets to change the look of your eBay page; and in the third, find out how to control the view of other eBayers' pages with your own browser. If you enjoyed these hacks, you'll find 97 more such tips and tricks in the book.

Hack #12. Tweaking Search URLs

Tap into eBay's massive database right from your own address bar.

eBay is essentially a massive database. Every time you view an auction page, you're just looking at a single database record. Every time you search, you're performing a query. But even if you're not familiar with DB lingo, you can play with eBay's URLs to tweak what you see.

Auction Pages

Many pages on eBay use a standard CGI (Common Gateway Interface) format, which is nothing more than a program name followed by a command and one or more parameters:

http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=3128013703

Here, cgi.ebay.com is the name of the server, eBayISAPI.dll is the filename of the program, ViewItem is the command to execute, and item=3128013703 is a parameter. Any additional parameters are separated by ampersands (&).

In this case, 3128013703 is the auction number. Simply replace this with another valid auction number, press Enter, and you'll see the corresponding auction page. This is typically quicker and more convenient than using the Search page to open an auction by its number.

TIP: Some sellers reference other auctions by simply including the auction number in their descriptions, usually because they don't know how to make links (see Hack #40). To view the auction by its number, simply copy and paste the number into the URL, replacing the one that's there.

Search Pages

A typical search page URL looks something like this:

http://search.ebay.com/ws/search/SaleSearch?satitle=avocado+green

Here, I searched for "avocado green", which you can see in the parameter satitle=avocado+green. Most searches will probably have more parameters, some more self-descriptive than others.

The real value in tweaking the URL is the ability to add or change options otherwise unavailable or inconveniently located in the search interface. One of the most useful of these is the self-evident sorecordsperpage option. Although you can choose this option by going to Search → Advanced Search → Results Per Page, this can be cumbersome, and you can't add it to an existing search you've already built. Instead, simply type the following at the end of an existing search URL:

&sorecordsperpage=100

Note the required ampersand (&) to separate this parameter from the one that precedes it. (In the old days, you could have up to 200 items on a page, but eBay has since reduced the limit to 100; anything higher will simply be ignored.) Here are some of the other parameters that are worth typing:

Parameter

Description

&sorecordsperpage=number

Number of search results to show per page, max=100

&sapricelo=price

Show only auctions above or equal to a certain price

&sapricehi=price

Show only auctions below or equal to a certain price

&sacategory=num+num+num

Restrict results to specified categories; see the next section

&sacategoryex=num+num+num

Exclude results from specified categories

&sasaleclass=class

Show (1) auctions only or (2) Buy-It-Now listings only

&sapaypal=1

Show only listings that accept PayPal

Searching in Categories

Although there's no way to specify a category directly in the search field, there is a quick way to convert a standard search to a category-specific search without having to drill down through layers of category links. (See Hack #11 for the long way.)

eBay has thousands of categories (more than 15,000 at the time of this writing), each identified by a unique category number. Although there's no obvious rhyme or reason to the numbering scheme, you may eventually learn the numbers of your favorite categories. The category number is easily found in the URL of the category listing; for example:

http://listings.ebay.com/aw/listings/list/category19116/index.html

Here, the category number is 19116. (You can also get the number of any category by viewing the complete list at listings.ebay.com/aw/plistings/list/categories.html.) To convert a standard search to a category-specific search, simply type the following at the end of the search URL:

&sacategory=19116

You can specify multiple category numbers by separating them with plus signs, something you can't do by clicking links on search pages.

TIP: Categories are typically restricted to a single nationality. For example, a given category number at ebay.com won't be recognized at ebay.de, even though ebay.de may have an equivalent category that goes by a different number. See Hack #15 for details.

View a Seller's Other Items

If you click "View seller's other items" on any auction page, you'll see a listing of all current auctions by that seller. Although you'll find even fewer options here than on the average search page, there are two important URL options you can tweak.

A seller's auction listing URL looks something like this:

http://cgi6.ebay.com/ws/eBayISAPI.dll?ViewSellersOtherItems
       &userid=some_user&since=-1&sort=3&rows=25

Related Articles:

Selling with eBay's New Auction Page -- In July 2003, eBay completely redesigned its standard auction page, the page that shows the details of any particular sale item. For sellers, these changes may have repercussions that ultimately affect their bottom line. In this article, David Karp, author of eBay Hacks, discusses several approaches eBayers can implement right away to help them communicate more effectively to customers about their auctions, and bring in the cash.

By default, only current auctions are shown here, but you can change the since parameter from -1 to any number up to 30 to view past auctions up to 30 days old. You can also change the rows parameter to specify how many auctions to show on a page; the maximum is 200.

It shouldn't take long to discover that typing either of these parameters into the URL is far quicker and more convenient than going to Search → By Seller, typing the seller's name, specifying the age and number of auctions to show, and clicking Search. But you probably saw that coming.

See Also

Hack #43. Overriding eBay's Fonts and Styles

Use Cascading Style Sheets to change the look of more than just the description.

The <font> tag, introduced in Hack #40, allows you to set the font for any block of text. But it won't have any effect on text outside the <font></font> structure, which means you can never control the appearance of any text outside the description area (e.g., the rest of the auction page). Instead, you'll have to use Cascading Style Sheets (CSS) if you want to apply your styles to the entire page.

The following code, for instance, will turn all text on the page green:

<style>     &callout1;
body,font,td,a {     &callout2;
  font-size: 10pt !important;
  font-family: Verdana,Arial,Helvetica !important;
  color: green !important;     &callout3;
}
</style>

Here's how it works. First, the <style></style> structure &callout1; sets apart our CSS definitions, which will take effect regardless of where the code is placed on the page. Next, a single CSS definition &callout2; lists the HTML tags to modify with our new styles. In this case, we are applying our styles to all <body> text, as well as to any text inside <font></font> tags, <td></td> tags (used for tables), and <a></a> tags (used for links). If you don't want to modify link colors, for instance, just remove ,a from line &callout2;.

The actual styles applied are listed between the curly braces { }, separated one per line for clarity. This includes the font size, the typeface, and, of course, our glorious green color &callout3;. The !important keywords ensure that our styles override any other styles defined elsewhere in the page, which is why even the section headers and the light gray text in the "Time left" section are overpowered by our choice.

If you feel that making all text the same color is a little drastic, you can customize it further:

<style>
body,font,td {
  font-family: Verdana,Arial,Helvetica !important;
  color: blue !important;
}
a {
  font-family: Verdana,Arial,Helvetica !important;
  color: orange !important;
}
</style>

This sets all ordinary text blue, except for links, which will appear orange (this will look pretty awful, by the way). Note the absence of font-size style, which will ensure that the original size of all text is preserved.

TIP: For a complete list of all the CSS styles you can use, you'll need dedicated CSS documentation such as Cascading Style Sheets: The Definitive Guide (O'Reilly), or the official W3C CSS specification (www.w3.org/Style/CSS/).

You can also use this technique to alter other aspects of the page. Don't like the blue shading section headers? Well, you can do something like this:

<style>
td { background-color: white !important; }
</style>

You may find this particular solution somewhat extreme, since it removes the shading used in every table on the page. But it will give you a taste of the power of CSS.

See Hack #41 for further auction-page hacking.

Override Other Sellers' Hacks

You'll eventually encounter an auction that has been hacked up pretty well, possibly by a seller with even worse taste than you. Fortunately, you may still have some control over the pages you view with your own browser.

TIP: Have you ever opened a page with a text/background combination that rendered the page nearly impossible to read? Here's a quick fix: just press Ctrl-A to highlight all text on the page. This will make all text appear white on a dark blue background, which will likely be a significant improvement.

You can set your browser preferences to favor your own color choices over those made by web site designers, but this can be a pain to turn on and off as needed. Instead, you may wish to set up a user stylesheet, a set of carefully constructed preferences and rules that will trump any crazy code like the stuff at the beginning of this hack. User stylesheets are supported by Netscape 6.x/Mozilla 1.x and later, and Internet Explorer 5.x and later.

See Also

Probably the best source for information about user stylesheets is Eric Meyer's CSS Anarchist's Cookbook. There, you'll find ways to "wreck" tables, disable banner ads, and render font coding pretty much useless, all worthwhile pursuits for the anarchist in each of us.

Hack #52. Let's Make a Deal

How to handle impatient bidders without losing customers and without getting kicked off eBay.

From time to time, bidders will contact you with special requests, such as those suggested in Hack #26 and Hack #27. How you respond to such requests and how you decide to conduct business is entirely up to you, but you'll want to be careful about some of the steps you take. As a seller on eBay, you'll have to walk a fine line between protecting yourself from dishonest bidders, not upsetting your honest bidders, not violating eBay policy, and not wasting large amounts of your time.

TIP: See who you're dealing with by taking a moment to look at their feedback and investigate their history, a process explained in Hack #53. That way, you'll know whether you should trust the bidder or add the bidder to your Blocked Bidder list (see Hack #54).

For instance, an impatient bidder might want to use Buy-It-Now on one of your auctions, even though the item has received bids and the option has disappeared from the page. The following are a few different approaches to dealing with this type of request, each with its own advantages and disadvantages:

Although the preceding example is the most common request of this sort, it's not the only one you'll receive. Bidders often contact sellers to ask for alternative colors, versions, etc., as well as related items and accessories, and a cooperative seller can stand to make quite a bit of extra money. Just be careful about how much you reach out to bidders.

If you're selling shoes, for example, it's generally acceptable to mention that you have other sizes and colors, either in other auctions (see Hack #47) or for sale in your online store. But this is different from posting a "dummy" auction whose purpose is to simply direct customers to your off-eBay store. Bidders won't buy it, and eBay won't tolerate it.

David A. Karp is the author of the bestselling Windows Annoyances series of books and the founder of Annoyances.org. He writes for PC Magazine and his latest books include eBay Hacks and the eBay: The Missing Manual.


Return to the Web DevCenter.

Copyright © 2009 O'Reilly Media, Inc.