Sometimes if you scroll waaaay down and read the fine print, it will say "compatible replacement", or some other words that mean that you're not actually getting what is in the big picture at the top of the page.
Depends on what kind of battery it is. I am in the US so I look at US suppliers.
For gel cells - the things that go in most every "computer" UPS under
1000 VA or so, house alarm systems, etc - I order from Digi-Key or Mouser, either Panasonic or Power-Sonic brand. I've been unhappy with every other brand of these that I've tried.For NiMH AAs, the only online shopping I've done is a pack of Eneloops from Amazon. As far as I can tell, I got genuine cells, and their performance has been as expected. Make sure it says "sold by and ships from Amazon.com" in the listing; I think there's a check box for that, which you can use when searching.
For a Li-ion battery for an older cell phone, I sighed deeply and bought from the seller with the most sales and best feedback who stocked that particular battery on eBay. I'm pretty sure I got a genuine battery, but it had an old date code; it had probably been sitting on the shelf for a couple of years. It took a few charge cycles to wake back up, but it is doing as well as can be expected.
I don't think I've ever bought alkaline / carbon-zinc primary batteries online. I've checked prices from online-only sellers, but in the small quantities of AAA, AA, C, D that I use, it's usually just about the same as going to the local discount store. For coin or button batteries, the local prices seem to be vastly inflated vs. online, but then the minimum shipping charge cuts in. If I happened to be ordering something else from Digi-Key or Mouser, then it might pay to order a coin cell from them.
For NiCd power tool batteries, I had my existing packs rebuilt by a local Batteries Plus store. I don't know what kind of cells they used, but they work a lot better than the worn-out original ones, and the rebuild price of about $35 was better than the new-pack price of $50+.
The last time I was involved with buying lead-acid traction batteries several years ago, I think the place where I worked got them directly from the manufacturer (Enersys, nee Hawker, nee Gates). That seemed to work OK.
Standard disclaimers apply: I don't get money or other consideration from any companies mentioned.
Matt Roberds