I’ve never really tried doing it in eBay but assuming you’re always using Paypal (and pay your eBay invoices via Paypal as well) then you can get good information that way.
Paypal / Activity / Detailed
Will give you a ‘spreadsheet’ of all your transactions showing the Paypal fees for each. If you click on statements/activity export you can download the data into Excel (or similar) and strip out your purchases if you use Paypal for buying and selling.
I suppose you need to add postage costs but I buy most of my postage through eBay anyway (it’s easy and doesn’t cost any more) so those costs go through paypal as well.