I guess you could use shaving cream to clean carpet spills in a pinch, but there are better things in your kitchen to use. If you have a carpet stain you would like to get rid of I recommend 2 cups of carbonated water and about 4 drops of dish washing soap. Yes, I said 4 drops of dish washing soap. It's no much but it's enough to break surface tension and release oils that might be present in the carpet stain.
So I recommend mixing 2 cups of carbonated water or still water with 4 drops of dish washing soap to clean minor spills and stains in your carpet. The first step is to blot up as much of the spill as possible. Next pour the above mixture onto the stain. Pour enough to cover the original spill without spreading it out further. I suggest pouring it around the outside of the carpet stain in a thin stream moving toward the center of the stain as you go. Once the carpet stain is completely covered give 30 to 40 seconds before you start to blot it up.
Take a white terry or microfiber towel and blot it up. Keep moving the towel to a new dry spot and blot some more. Feel free to use 2 or 3 towels during the process. If the carpet stain removal process hasn't removed all the spill then repeat the process again. If you can't remove the entire spot call a professional carpet cleaner to come take a look.
For carpet stain removal in Tampa FL call Chem-Dry of Tampa.