Really the number one best remedy is to act very quickly. This is the best way to treat any stain. In fact this weekend I was painting my daughters room when I carelessly rolled the paint roller onto the carpet, not just a little drop of paint either. I left at least a 3 by 2 inch blotch of paint on the carpet. So immediately I grab several terry towels and cleaning cloths and a cup of water (thankfully the paint was water based). I blot up with the dry terry cleaning towel, and then apply water to the stain and blot using a dry towel until the stain was completely removed. This took several applications of a little water and blotting action with the dry towels. Leaving this stain for any amount of time would have left the carpet with a permanent purple stain. However the quick action left no evidence of my carelessness.
Here are some other general carpet cleaning tips:
Blot or scrape up if the spill is thicker than a regular liquid (cat vomit etc.), remove as much as you can this first.
Never scrub or rub a spill, you will end up spreading and pushing the stain deeper.
Apply water or stain remover from the outside in on the stain and blot up…
If you use a stain remover test a small spot first in an unseen area to be sure its safe on your carpet. However if you act right away most stains can be cleaning with water and a small amount of dish detergent mixed in, then rinse with plain water.