When I poop it feels very painful like there is a scraping happening in my anus. What should I do to get rid of this pain?

Probable fissure. It sounds like you have an anal fissure. You should consult your doctor for treatment. In the mean time take a stool softner to lessen the pain and improve the chance of healing.
Sounds like a fissur. If you have a tearing, ripping sensation when having a bowel movement, you probably have a fissure. You need to be seen by a colorectal surgeon for advice on how to best manage it and get it to heal.