Hi, Sarah. For either smell, the answer is the same. First, wash the area with white vinegar in a sponge and lightly rinse. You can vaccuum with a wet/dry vacuum cleaner, if possible, to get out most of the remaining water and/or blot up as much water as possible with towels.
If this is not successful, then sprinkle a box or 2 of baking soda over the area. You don't have to bury the carpet in it, just be a little on the generous side. After 24 hours, vacuum up the baking soda nd the smell will come up with it.