This is sort of a tough question to answer , that solely falls down to the fact that its hard to automatically get the fees for a certain token.
Manually however , I imagine with your expertise in coding you can read that easily through the contract.
However I have two plausible solutions here.
some contracts have their read fees as a public function
meaning you can acquire how much they take for fees via a function call
as you may suspect however this presents a lot of problems most notably not every contract has these , and also the read function's name to get fees inflicted changes from contract to another
Recommended way but also hard: you can technically take the contract's address and its ABI and deploy it on a local testing blockchain like ganache and initiate a a swap to that contract (You would also need to fork uniswap on your local blockchain) and from there you can calculate how many tokens you lost as a roundtrip all automatically
for example if you simulated a buy of 500 tokens and you came out with 400 tokens then the buy tax is 20%.
you can do the same thing for the sell and find out that tax on sells.
I understand this is a complicated and hard way to find out fees on tokens but this is the only 100% guaranteed way of doing it.
a third solution but not so automatic , is to manually put in the fees for that contract after reading the smart contract yourself