The minor constituent found in Acanthus ilicifolius Linnaeus, 4-hydroxy-2 (3H) benzoxazolone alkaloid (HBOA), has a range of versatile applications. Herein, a quick and straightforward method for extracting HBOA from A. ilicifolius Linnaeus was proposed. HBOA was used as a template, whereas methacrylic acid, ethylene glycol dimethacrylate, and acetonitrile were used as functional monomers, cross-linkers, and porogens, respectively. Molecularly imprinted polymers (MIPs) were synthesized by precipitation polymerization, and their adsorption isotherms, dynamics, and selective binding ability were characterized and analyzed. The results showed that the adsorption amount of the template was 90.18 mg/g. The MIPs were used as solid-phase extraction fillers and actual sample extraction columns, with a linear range of 0–100 μg/L, average recovery of 78.50–101.12%, and a relative standard deviation of 1.20–3.26%. The HBOA concentrations in the roots, stems, and leaves were 1,226, 557, and 205 μg/g, respectively. In addition, MIP–SPE was successfully used in isolating and purifying HBOA from different parts of A. ilicifolius Linnaeus, indicating its effectiveness in extracting and determining HBOA in other herbs.