Do you have a piece that is big enough to completely cover the stained area?
If so, I have had excellent success at cutting out the stained area and replacing it with a new piece. If the carpet is fairly new, the repair will be invisible.
A carpet installer is the safest way to go on this, but I have done it myself several times and it has always worked out just fine.
I don't have a carpet seamer and the DIY seaming tape they sell is not really that good. What I have found is that if I buy the heaviest canvas available, wash it first and cut it into strips about 12" wide, I can cut out a freeform section of carpet, with a single-edge razor blade, cut a new piece to an exact fit and seam them together. Try to match the "grain" of the carpet. Place the canvas under the existing, already installed carpet so that half is under the carpet & half is exposed. Lift up the carpet and liberally apply Elmer's wood glue to the entire canvas surfact. Let the carpet drop back in place, place the patch on the exposed canvas & glue, and weight it down with something flat & heavy.
The next morning all will be well.