My opinion may not be much, but as a male, I think we've all struggled with it at some point in life.
One thing I've learned is look at the situation in which you find yourself that causes you to fall into sin. Is it talking with a member of the opposite sex? Are you doing this when no one's home? Are you bored when it happens? Do your thoughts wander in that direction so you decide to give in?
My biggest problem was the muscle memory of typing in the addresses of those sites. So, if/when the urge comes, I consiously stop and type in the forum address here, or maybe pull up YouTube and look up religious videos. Or maybe read up on a hobby. Divert your attention to something else.
Some say pray the Rosary when the urge comes. I think the idea though is to deliberately do something else. Another thing I've learned is after a while it gets easier. Baby steps!
It may not be easy, but with the help of the Holy Spirit and prayer, you can pull through it.
God bless you.