web3 calculate gas and set slippage

Job ID: 32048654

Budget: $10 – $30 USD

I have built a web3 script that allows me to swap tokens on pancakeswap. I am having one issue I would like help with. I would like my script to before sending the transaction, calculate the gasprice and gas. Then like how pancakeswap works, I would like the order to not go through if the slippage would exceed a certain amount. If minimum amount to receive is better than slippage and estimated gasprice is below certain limit, then execute the transaction.
Related categories: Python Ethereum Web3.js