Fast and efficient sample pretreatment is the prerequisite for realizing surface-enhanced Raman spectroscopy (SERS) detection of trace targets in complex matrices, which is still a big issue for the practical application of SERS. Recently, we have proposed a highly performed liquid-liquid extraction (LLE)-back extraction (BE) for weak acids/bases extraction in drinking water and beverage samples. However, the performance efficiency decreased drastically on facing matrices like food and biological blood. Based on the total interaction energies among target, interferent, and extractant molecules, solid-phase extraction (SPE) with a higher selectivity was introduced in advance of LLE-BE, which enabled the sensitive (μg L-1 level) and rapid (within 10 min) SERS detection of both koumine (a weak base) and celastrol (a weak acid) in different food and biological samples. Further, the high SERS sensitivity was determined unmanned by Vis-CAD (a machine learning algorithm), instead of the highly demanded expert recognition. The generality of SPE-LLE-BE for various weak acids/bases (2 < pKa < 12), accompanied by the high efficiency, easy operation, and low cost, offers SERS as a powerful on-site and efficient inspection tool in food safety and forensics.