The best liquid to clean a carpet with is water, with a little added carpet shampoo or detergent if needed. There is often no need for anything harsher than this, as it could damage the carpet or rug, or make the problem worse. Just be sure to only use detergent designed for use on carpets, rather than dish detergent or laundry detergent, as this may damage the carpet fibers or cause excess bubbles that are hard to remove.