Capecitabine (CAP) is a kind of prodrug that can be metabolized into 5-fluorouracil (5-FU) in vivo, so it is usually classified as the antimetabolite fluoropyrimidine deoxynucleoside analog. In this paper, CAP, upconversion nanoparticles (UCNPs), 3,5-dicarboxy-4-methacrylate-based azobenzene (MAPDIA)/acrylic acid-functionalized gelatin, N,N′-methylene bisacrylamide (MBA), and ammonium persulfate (APS) were used as template, light trigger, bifunctional monomers, cross-linking agent and initiator, respectively. By using the free-radical polymerization and the molecular imprinting technique, the potential drug delivery nanocontainer CAP-MIP with the dual-responsive performance to pH/near infrared light (NIR) was successfully prepared. Furthermore, the characterization of CAP-MIP was also carried out by the modern instrumental analysis such as FTIR, XRD, TGA, BET and so on. The stimulus-responsive release experiment in vitro indicated the maximum cumulative release rate of CAP changed from 1.71 % to 89.54 % when the pH value in medium varied from 1.2 to 8.3, and the equilibrium release time point also greatly prolonged to 420 min from 40 min, respectively. When irradiated by 980 nm monochromatic NIR light in the same solution of pH 6.8, the maximum release rate of the sample could reach 96.21 % at 180 min, which respectively corresponded to the data of 41.84 % at 420 min under the condition of the absence of additional NIR light. In addition, CAP-MIP also had the excellent specific adsorption for CAP with the selectivity factor of 2.904 and the maximum CAP-loaded capacity of 7 mg•g−1. The above information denoted the target material should be of some potential in drug delivery system application.