Efficient magnetic solid phase extraction using covalent organic frameworks (COFs) can find important applications in food safety. In this work, a sulfonate-functionalized magnetic COF (Fe3O4@COF-SO3Na) was synthesized by self-polycondensation of two-in-one monomer 1,6-bis(4-formylphenyl)-3,8-bis((4-aminophenyl) ethynyl)) pyrene (BFBAEPy) on the surface of aminated Fe3O4 and a thiol-yne click reaction. It was further adopted as an adsorbent for the efficient magnetic solid-phase extraction (MSPE) of basic orange II. The selective adsorption experiment indicated that it displayed selective adsorption ability to basic orange II due to the ion exchange, hydrogen bonds, and π-π interactions. Under the optimized conditions, the proposed MSPE method coupled with HPLC-DAD showed excellent linearity in the range of 0.05–0.5 µg/mL (R2 = 0.9997) for basic orange II. The lower limits of detection (LODs) for basic orange II were 1.0–1.4 µg/L for three food samples: yellow croaker, paprika and dried bean curd. The recoveries were 90.1–98.8% with relative standard deviations (RSDs) below 4.2%. Therefore, this work provides an effective strategy to modify magnetic COFs as absorbents in MSPE. Due to the tunability of functional groups in thiol‑yne click reactions, the functional groups of magnetic COFs can be readily designed to enrich their multifunctional applications. Meanwhile, this work proposed a new method to detect trace amounts of basic orange II in food samples.