A novel polystyrene/pyridine composite nanofiber was synthesized and utilized as the sorbent material for the solid‐phase extraction of bisphenol A and five common phthalate esters in milk. The method of extraction integrated extraction and preconcentration of target analytes into a single step. Bisphenol A and five common phthalate esters were selected as target compounds for the development and evaluation of the method. The effects of operating parameters for nanofiber‐based solid‐phase extraction, such as selection and amount of sorbent, the volume fraction of perchlorate (precipitate protein), desorption solvent, volume of desorption solvent, and effect of salt addition were optimized. Under optimal conditions, higher extraction recoveries (89.6–118.0%) of the six compounds in milk spiked at three levels were obtained, and the satisfied relative standard deviation were ranged from 0.6 to 10.9%. The detection limits and quantification limits of the method ranged from 0.01 to 0.06 μg/L and 0.05 to 0.53 μg/L, respectively. Matrix effects were also verified and well controlled in the range of 91.3–109.3%. The new method gave better performance metrics than Chinese standard method and other published methods. Thus, the proposed method may be applied to the analysis of the phthalate esters and bisphenol A in complex matrixes.